21 #ifndef __TBB_spin_mutex_H 22 #define __TBB_spin_mutex_H 26 #include "aligned_space.h" 27 #include "tbb_stddef.h" 28 #include "tbb_machine.h" 29 #include "tbb_profiling.h" 30 #include "internal/_mutex_padding.h" 40 class spin_mutex : internal::mutex_copy_deprecated_and_disabled {
42 __TBB_atomic_flag flag;
48 #if TBB_USE_THREADING_TOOLS 63 __TBB_Flag my_unlock_value;
66 void __TBB_EXPORTED_METHOD internal_acquire(
spin_mutex& m );
69 bool __TBB_EXPORTED_METHOD internal_try_acquire(
spin_mutex& m );
72 void __TBB_EXPORTED_METHOD internal_release();
82 internal::suppress_unused_warning(my_unlock_value);
83 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 88 __TBB_LockByte(m.flag);
94 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 98 __TBB_LockByte(m.flag);
105 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 106 return internal_try_acquire(m);
108 bool result = __TBB_TryLockByte(m.flag);
117 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 120 __TBB_UnlockByte(my_mutex->flag);
128 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 131 __TBB_UnlockByte(my_mutex->flag);
141 static const bool is_rw_mutex =
false;
142 static const bool is_recursive_mutex =
false;
143 static const bool is_fair_mutex =
false;
149 #if TBB_USE_THREADING_TOOLS 153 __TBB_LockByte(flag);
160 #if TBB_USE_THREADING_TOOLS 164 return __TBB_TryLockByte(flag);
170 #if TBB_USE_THREADING_TOOLS 174 s.internal_release();
176 __TBB_store_with_release(flag, 0);
187 #if ( __TBB_x86_32 || __TBB_x86_64 ) 188 #include "internal/_x86_eliding_mutex_impl.h" 203 #if ( __TBB_x86_32 || __TBB_x86_64 ) 208 __TBB_DEFINE_PROFILING_SET_NAME(speculative_spin_mutex)
scoped_lock(spin_mutex &m)
Construct and acquire lock on a mutex.
Definition: spin_mutex.h:81
interface7::internal::padded_mutex< spin_mutex, false > speculative_spin_mutex
A cross-platform spin mutex with speculative lock acquisition.
Definition: spin_mutex.h:206
~scoped_lock()
Destroy lock. If holding a lock, releases the lock first.
Definition: spin_mutex.h:126
void lock()
Acquire lock.
Definition: spin_mutex.h:148
void release()
Release lock.
Definition: spin_mutex.h:116
bool try_acquire(spin_mutex &m)
Try acquiring lock (non-blocking)
Definition: spin_mutex.h:104
bool try_lock()
Try acquiring lock (non-blocking)
Definition: spin_mutex.h:159
Block of space aligned sufficiently to construct an array T with N elements.
Definition: aligned_space.h:33
void __TBB_EXPORTED_METHOD internal_construct()
Internal constructor with ITT instrumentation.
Represents acquisition of a mutex.
Definition: spin_mutex.h:54
spin_mutex()
Construct unacquired lock.
Definition: spin_mutex.h:47
Definition: _mutex_padding.h:36
T * begin()
Pointer to beginning of array.
Definition: aligned_space.h:39
void acquire(spin_mutex &m)
Acquire lock.
Definition: spin_mutex.h:93
A lock that occupies a single byte.
Definition: spin_mutex.h:40
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
void unlock()
Release lock.
Definition: spin_mutex.h:169
scoped_lock()
Construct without acquiring a mutex.
Definition: spin_mutex.h:78