MeshLib C++ Docs
Loading...
Searching...
No Matches
MRTbbThreadMutex.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4
5#include "MRPch/MRBindingMacros.h"
6
7#include <atomic>
8#include <optional>
9#include <thread>
10
11namespace MR
12{
15
16
35{
36public:
39 MRMESH_API explicit TbbThreadMutex( std::thread::id id = std::this_thread::get_id() );
40
43 {
44 friend class TbbThreadMutex;
45 TbbThreadMutex* mutex_{ nullptr };
46
47 explicit LockGuard( TbbThreadMutex& mutex ) : mutex_( &mutex ) {}
48
49 public:
50 LockGuard( const LockGuard& ) = delete;
51 MRMESH_API LockGuard( LockGuard&& other );
52
53 MRMESH_API ~LockGuard();
54 };
55
58 MRMESH_API std::optional<LockGuard> tryLock();
59
60private:
61 std::thread::id id_;
62 std::atomic_flag lockFlag_;
63};
64
65}
RAII-style lock guard for the mutex; releases it on destruction.
Definition MRTbbThreadMutex.h:43
Definition MRTbbThreadMutex.h:35
MRMESH_API LockGuard(LockGuard &&other)
MRMESH_API TbbThreadMutex(std::thread::id id=std::this_thread::get_id())
LockGuard(const LockGuard &)=delete
MRMESH_API std::optional< LockGuard > tryLock()
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
only for bindings generation
Definition MRCameraOrientationPlugin.h:8