job_queue.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Bielefeld University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Bielefeld University nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Robert Haschke */
36 
37 #pragma once
38 #include <QObject>
39 
40 #include <QObject>
41 #include <deque>
42 #include <functional>
43 #include <boost/thread/mutex.hpp>
44 #include <boost/thread/condition_variable.hpp>
45 
46 namespace moveit {
47 namespace tools {
48 
50 class JobQueue : public QObject
51 {
52  Q_OBJECT
53  boost::mutex jobs_mutex_;
54  std::deque<std::function<void()> > jobs_;
55  boost::condition_variable idle_condition_;
56 
57 public:
58  explicit JobQueue(QObject* parent = nullptr);
59  void addJob(const std::function<void()>& job);
60  void clear();
61  size_t numPending();
62 
63  void waitForAllJobs();
64  void executeJobs();
65 };
66 } // namespace tools
67 } // namespace moveit
moveit::tools::JobQueue::addJob
void addJob(const std::function< void()> &job)
Definition: job_queue.cpp:109
moveit::tools::JobQueue::executeJobs
void executeJobs()
Definition: job_queue.cpp:129
moveit::tools::JobQueue::jobs_
std::deque< std::function< void()> > jobs_
Definition: job_queue.h:150
moveit::tools::JobQueue::clear
void clear()
Definition: job_queue.cpp:114
moveit::tools::JobQueue::waitForAllJobs
void waitForAllJobs()
Definition: job_queue.cpp:123
moveit::tools::JobQueue::numPending
size_t numPending()
Definition: job_queue.cpp:118
moveit::tools::JobQueue::jobs_mutex_
boost::mutex jobs_mutex_
Definition: job_queue.h:149
moveit::tools::JobQueue::idle_condition_
boost::condition_variable idle_condition_
Definition: job_queue.h:151
moveit
moveit::tools::JobQueue::JobQueue
JobQueue(QObject *parent=nullptr)
Definition: job_queue.cpp:107


visualization
Author(s): Robert Haschke
autogenerated on Thu Feb 27 2025 03:39:51