| 56 | } |
| 57 | |
| 58 | void mutex::scoped_lock::internal_release() { |
| 59 | __TBB_ASSERT( my_mutex, "mutex::scoped_lock: not holding a mutex" ); |
| 60 | #if _WIN32||_WIN64 |
| 61 | switch( my_mutex->state ) { |
| 62 | case INITIALIZED: |
| 63 | __TBB_ASSERT(false,"mutex::scoped_lock: try to release the lock without acquisition"); |
| 64 | break; |
| 65 | case HELD: |
| 66 | my_mutex->state = INITIALIZED; |
| 67 | LeaveCriticalSection(&my_mutex->impl); |
| 68 | break; |
| 69 | case DESTROYED: |
| 70 | __TBB_ASSERT(false,"mutex::scoped_lock: mutex already destroyed"); |
| 71 | break; |
| 72 | default: |
| 73 | __TBB_ASSERT(false,"mutex::scoped_lock: illegal mutex state"); |
| 74 | break; |
| 75 | } |
| 76 | #else |
| 77 | int error_code = pthread_mutex_unlock(&my_mutex->impl); |
| 78 | __TBB_ASSERT_EX(!error_code, "mutex::scoped_lock: pthread_mutex_unlock failed"); |
| 79 | #endif /* _WIN32||_WIN64 */ |
| 80 | my_mutex = NULL; |
| 81 | } |
| 82 | |
| 83 | bool mutex::scoped_lock::internal_try_acquire( mutex& m ) { |
| 84 | #if _WIN32||_WIN64 |