MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / internal_try_acquire

Method internal_try_acquire

benchmarks/tbb/mutex.cpp:83–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool mutex::scoped_lock::internal_try_acquire( mutex& m ) {
84#if _WIN32||_WIN64
85 switch( m.state ) {
86 case INITIALIZED:
87 case HELD:
88 break;
89 case DESTROYED:
90 __TBB_ASSERT(false,"mutex::scoped_lock: mutex already destroyed");
91 break;
92 default:
93 __TBB_ASSERT(false,"mutex::scoped_lock: illegal mutex state");
94 break;
95 }
96#endif /* _WIN32||_WIN64 */
97
98 bool result;
99#if _WIN32||_WIN64
100 result = TryEnterCriticalSection(&m.impl)!=0;
101 if( result ) {
102 __TBB_ASSERT(m.state!=HELD, "mutex::scoped_lock: deadlock caused by attempt to reacquire held mutex");
103 m.state = HELD;
104 }
105#else
106 result = pthread_mutex_trylock(&m.impl)==0;
107#endif /* _WIN32||_WIN64 */
108 if( result )
109 my_mutex = &m;
110 return result;
111}
112
113void mutex::internal_construct() {
114#if _WIN32||_WIN64

Callers 3

try_lockMethod · 0.45
try_lockMethod · 0.45
try_lockMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected