26 #if __TBB_TSX_AVAILABLE 37 EnterCriticalSection( &m.
impl );
47 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
50 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
54 int error_code = pthread_mutex_lock(&m.
impl);
62 __TBB_ASSERT( my_mutex,
"mutex::scoped_lock: not holding a mutex" );
64 switch( my_mutex->state ) {
66 __TBB_ASSERT(
false,
"mutex::scoped_lock: try to release the lock without acquisition");
70 LeaveCriticalSection(&my_mutex->impl);
73 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
76 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
80 int error_code = pthread_mutex_unlock(&my_mutex->impl);
81 __TBB_ASSERT_EX(!error_code,
"mutex::scoped_lock: pthread_mutex_unlock failed");
93 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
96 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
103 result = TryEnterCriticalSection(&m.
impl)!=0;
105 __TBB_ASSERT(m.state!=
HELD,
"mutex::scoped_lock: deadlock caused by attempt to reacquire held mutex");
109 result = pthread_mutex_trylock(&m.
impl)==0;
118 InitializeCriticalSectionEx(&
impl, 4000, 0);
121 int error_code = pthread_mutex_init(&
impl,NULL);
132 DeleteCriticalSection(&
impl);
138 __TBB_ASSERT(
false,
"mutex: illegal state for destruction");
143 int error_code = pthread_mutex_destroy(&
impl);
144 #if __TBB_TSX_AVAILABLE
static bool speculation_enabled()
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define ITT_SYNC_CREATE(obj, type, name)
mutex * my_mutex
The pointer to the current mutex to work.
void __TBB_EXPORTED_METHOD internal_release()
All checks from release using mutex.state were moved here.
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
#define _T(string_literal)
Standard Windows style macro to markup the string literals.
void __TBB_EXPORTED_METHOD internal_construct()
All checks from mutex constructor using mutex.state were moved here.
bool __TBB_EXPORTED_METHOD internal_try_acquire(mutex &m)
All checks from try_acquire using mutex.state were moved here.
void __TBB_EXPORTED_METHOD internal_destroy()
All checks from mutex destructor using mutex.state were moved here.
Wrapper around the platform's native lock.
void __TBB_EXPORTED_FUNC handle_perror(int error_code, const char *aux_info)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info.
void __TBB_EXPORTED_METHOD internal_acquire(mutex &m)
All checks from acquire using mutex.state were moved here.