MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::TbbThreadMutex Class Reference

#include <MRMesh/MRTbbThreadMutex.h>

Classes

class  LockGuard
 RAII-style lock guard for the mutex; releases it on destruction. More...

Public Member Functions

 TbbThreadMutex (std::thread::id id=std::this_thread::get_id())
std::optional< LockGuardtryLock ()

Detailed Description

helper class used to ensure that the specific thread is not re-used by TBB use it if you have nested TBB operations (e.g. parallel_for inside another parallel_for)

TbbThreadMutex reportThreadMutex;
tbb::parallel_for( range, [&] ( auto&& range )
{
const auto reportThreadLock = reportThreadMutex.tryLock();
for ( auto i = range.begin(); i != range.end(); ++i )
{
tbb::parallel_for( ... );
if ( reportThreadLock )
report( ... );
}
} );
TbbThreadMutex(std::thread::id id=std::this_thread::get_id())
std::optional< LockGuard > tryLock()

The documentation for this class was generated from the following file: