22 #if __TBB_TSX_AVAILABLE 33 EnterCriticalSection( &m.
impl );
43 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
46 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
50 int error_code = pthread_mutex_lock(&m.
impl);
58 __TBB_ASSERT( my_mutex,
"mutex::scoped_lock: not holding a mutex" );
60 switch( my_mutex->state ) {
62 __TBB_ASSERT(
false,
"mutex::scoped_lock: try to release the lock without acquisition");
66 LeaveCriticalSection(&my_mutex->impl);
69 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
72 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
76 int error_code = pthread_mutex_unlock(&my_mutex->impl);
77 __TBB_ASSERT_EX(!error_code,
"mutex::scoped_lock: pthread_mutex_unlock failed");
89 __TBB_ASSERT(
false,
"mutex::scoped_lock: mutex already destroyed");
92 __TBB_ASSERT(
false,
"mutex::scoped_lock: illegal mutex state");
99 result = TryEnterCriticalSection(&m.
impl)!=0;
101 __TBB_ASSERT(m.state!=
HELD,
"mutex::scoped_lock: deadlock caused by attempt to reacquire held mutex");
105 result = pthread_mutex_trylock(&m.
impl)==0;
114 InitializeCriticalSectionEx(&
impl, 4000, 0);
117 int error_code = pthread_mutex_init(&
impl,NULL);
128 DeleteCriticalSection(&
impl);
134 __TBB_ASSERT(
false,
"mutex: illegal state for destruction");
139 int error_code = pthread_mutex_destroy(&
impl);
140 #if __TBB_TSX_AVAILABLE void __TBB_EXPORTED_METHOD internal_destroy()
All checks from mutex destructor using mutex.state were moved here.
mutex * my_mutex
The pointer to the current mutex to work.
#define ITT_SYNC_CREATE(obj, type, name)
bool __TBB_EXPORTED_METHOD internal_try_acquire(mutex &m)
All checks from try_acquire using mutex.state were moved here.
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_release()
All checks from release using mutex.state were moved here.
#define _T(string_literal)
Standard Windows style macro to markup the string literals.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
void __TBB_EXPORTED_METHOD internal_construct()
All checks from mutex constructor using mutex.state were moved here.
Wrapper around the platform's native lock.
void __TBB_EXPORTED_METHOD internal_acquire(mutex &m)
All checks from acquire using mutex.state were moved here.
static bool speculation_enabled()