TaskGroup.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_TRANSPORT_TASKGROUP_HH_
18 #define GAZEBO_TRANSPORT_TASKGROUP_HH_
19 
20 #include <utility>
21 
22 // Emit is both a macro in Qt and a function defined by tbb
23 #undef emit
24 #include <tbb/tbb.h>
25 #define emit
26 
27 namespace gazebo {
28  namespace transport {
29  class TaskGroup
30  {
31  public: ~TaskGroup() noexcept
32  {
33  // Wait for running tasks to finish
34  this->taskGroup.wait();
35  }
36 
37  public: template<class Functor, class... Args> void run(Args&&... args)
38  {
39  this->taskGroup.run(Functor(std::forward<Args>(args)...));
40  }
41 
42  private: tbb::task_group taskGroup;
43  };
44  }
45 }
46 
47 #endif
transport
Definition: ConnectionManager.hh:38
Definition: TaskGroup.hh:30
~TaskGroup() noexcept
Definition: TaskGroup.hh:31
void run(Args &&... args)
Definition: TaskGroup.hh:37
Forward declarations for the common classes.
Definition: Animation.hh:27