22 #if __TBB_TSX_AVAILABLE 27 void mutex::scoped_lock::internal_acquire( mutex& m ) {
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);
57 void mutex::scoped_lock::internal_release() {
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");
65 my_mutex->state = INITIALIZED;
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");
82 bool mutex::scoped_lock::internal_try_acquire( mutex& m ) {
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;
112 void mutex::internal_construct() {
114 InitializeCriticalSectionEx(&impl, 4000, 0);
117 int error_code = pthread_mutex_init(&impl,NULL);
124 void mutex::internal_destroy() {
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_FUNC handle_perror(int error_code, const char *aux_info)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info.
#define _T(string_literal)
Standard Windows style macro to markup the string literals.
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
#define ITT_SYNC_CREATE(obj, type, name)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
static bool speculation_enabled()