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

#include <MRTbbThreadMutex.h>

Classes

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

Public Member Functions

MRMESH_API TbbThreadMutex (std::thread::id id=std::this_thread::get_id())
 
MRMESH_API 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( ... );
}
} );
Definition MRTbbThreadMutex.h:35
MRMESH_API std::optional< LockGuard > tryLock()

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