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
42 class LockGuard
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
54 };
55
58 MRMESH_API std::optional<LockGuard> tryLock();
59
60private:
61 std::thread::id id_;
62 std::atomic_flag lockFlag_;
63};
64
65}
#define MRMESH_API
Definition MRMeshFwd.h:80
RAII-style lock guard for the mutex; releases it on destruction.
Definition MRTbbThreadMutex.h:43
LockGuard(LockGuard &&other)
LockGuard(const LockGuard &)=delete
friend class TbbThreadMutex
Definition MRTbbThreadMutex.h:44
TbbThreadMutex(std::thread::id id=std::this_thread::get_id())
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
std::optional< LockGuard > tryLock()
@ other
Angle, normally float. Measure in radians.
Definition MRFeatureObject.h:27
only for bindings generation
Definition MRCameraOrientationPlugin.h:8