-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace deprecated tbb task for tbb >= 2021 (#3174)
As tbb::task has been removed in oneTBB 2021.01, we need to replace its use with oneapi::tbb::task_group. Define a wrapper so that tbb::task_group is used for newer versions of oneTBB. Fixes #2867. * Fix typo * Remove TopicManagerProcessTask as it is unused * Use oneapi::tbb::task_group instead of tbb::task if available * Assign my copyright to OSRF * Add myself to AUTHORS * Default to using tbb::task for older versions of TBB, to maintain ABI * Replace use of tbb/version.h with tbb/tbb.h As tbb/version.h is seemingly not present before v2021.01, it cannot be used to get the definition for TBB_VERSION_MAJOR, so let's use the main tbb.h header which is present on all versions. Signed-off-by: Alex Dewar <alex.dewar@gmx.co.uk> * Make sure that there are no ABI changes for tbb < 2021 * Fix linking problems * Undef more emit symboles for tbb includes * Remove trailing whitespace Signed-off-by: Steve Peters <scpeters@openrobotics.org> * Cleanup TAskGroup as it is used only if tbb>=2021 * If tbb >= 2021 add TBB::tbb to GAZEBO_LIBRARIES for downstream users * Fix CMake configuration failure with tbb 2020 * Fix GAZEBO_TRANSPORT_TASKGROUP_HH_ header guard * For tbb >= 2021 make PublishTask::operator() const * Unpin tbb-devel Co-authored-by: Alex Dewar <a.dewar@sussex.ac.uk> Co-authored-by: Alex Dewar <alex.dewar@gmx.co.uk> Co-authored-by: Steve Peters <scpeters@openrobotics.org>
- Loading branch information
1 parent
34ebf4e
commit ea95601
Showing
12 changed files
with
168 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Alex Dewar <alex.dewar@gmx.co.uk> | ||
Nate Koenig <nkoenig@osrfoundation.org> | ||
John Hsu <hsu@osrfoundation.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef GAZEBO_TRANSPORT_TASKGROUP_HH_ | ||
#define GAZEBO_TRANSPORT_TASKGROUP_HH_ | ||
|
||
#include <utility> | ||
|
||
// Emit is both a macro in Qt and a function defined by tbb | ||
#undef emit | ||
#include <tbb/tbb.h> | ||
#define emit | ||
|
||
namespace gazebo { | ||
namespace transport { | ||
class TaskGroup | ||
{ | ||
public: ~TaskGroup() noexcept | ||
{ | ||
// Wait for running tasks to finish | ||
this->taskGroup.wait(); | ||
} | ||
|
||
public: template<class Functor, class... Args> void run(Args&&... args) | ||
{ | ||
this->taskGroup.run(Functor(std::forward<Args>(args)...)); | ||
} | ||
|
||
private: tbb::task_group taskGroup; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.