35 EnterCriticalSection( &m.
impl );
38 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: mutex already destroyed");
41 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: illegal mutex state");
45 int error_code = pthread_mutex_lock(&m.
impl);
53 __TBB_ASSERT( my_mutex,
"recursive_mutex::scoped_lock: not holding a mutex" );
55 switch( my_mutex->state ) {
57 LeaveCriticalSection( &my_mutex->impl );
60 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: mutex already destroyed");
63 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: illegal mutex state");
67 int error_code = pthread_mutex_unlock(&my_mutex->impl);
68 __TBB_ASSERT_EX(!error_code,
"recursive_mutex::scoped_lock: pthread_mutex_unlock failed");
79 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: mutex already destroyed");
82 __TBB_ASSERT(
false,
"recursive_mutex::scoped_lock: illegal mutex state");
88 result = TryEnterCriticalSection(&m.
impl)!=0;
90 result = pthread_mutex_trylock(&m.
impl)==0;
99 InitializeCriticalSectionEx(&
impl, 4000, 0);
102 pthread_mutexattr_t mtx_attr;
103 int error_code = pthread_mutexattr_init( &mtx_attr );
107 pthread_mutexattr_settype( &mtx_attr, PTHREAD_MUTEX_RECURSIVE );
108 error_code = pthread_mutex_init( &
impl, &mtx_attr );
111 pthread_mutexattr_destroy( &mtx_attr );
120 DeleteCriticalSection(&
impl);
123 __TBB_ASSERT(
false,
"recursive_mutex: already destroyed");
126 __TBB_ASSERT(
false,
"recursive_mutex: illegal state for destruction");
131 int error_code = pthread_mutex_destroy(&
impl);
132 __TBB_ASSERT_EX(!error_code,
"recursive_mutex: pthread_mutex_destroy failed");
void __TBB_EXPORTED_METHOD internal_destroy()
All checks from mutex destructor using mutex.state were moved here.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define ITT_SYNC_CREATE(obj, type, name)
#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.
void __TBB_EXPORTED_METHOD internal_acquire(recursive_mutex &m)
All checks from acquire using mutex.state were moved here.
Mutex that allows recursive mutex acquisition.
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.
recursive_mutex * my_mutex
The pointer to the current recursive_mutex to work.
bool __TBB_EXPORTED_METHOD internal_try_acquire(recursive_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.