A method to acquire queuing_mutex lock
| 30 | |
| 31 | //! A method to acquire queuing_mutex lock |
| 32 | void queuing_mutex::scoped_lock::acquire( queuing_mutex& m ) |
| 33 | { |
| 34 | __TBB_ASSERT( !this->mutex, "scoped_lock is already holding a mutex"); |
| 35 | |
| 36 | // Must set all fields before the fetch_and_store, because once the |
| 37 | // fetch_and_store executes, *this becomes accessible to other threads. |
| 38 | mutex = &m; |
| 39 | next = NULL; |
| 40 | going = 0; |
| 41 | |
| 42 | // The fetch_and_store must have release semantics, because we are |
| 43 | // "sending" the fields initialized above to other processors. |
| 44 | scoped_lock* pred = m.q_tail.fetch_and_store<tbb::release>(this); |
| 45 | if( pred ) { |
| 46 | ITT_NOTIFY(sync_prepare, mutex); |
| 47 | #if TBB_USE_ASSERT |
| 48 | __TBB_control_consistency_helper(); // on "m.q_tail" |
| 49 | __TBB_ASSERT( !pred->next, "the predecessor has another successor!"); |
| 50 | #endif |
| 51 | pred->next = this; |
| 52 | spin_wait_while_eq( going, 0ul ); |
| 53 | } |
| 54 | ITT_NOTIFY(sync_acquired, mutex); |
| 55 | |
| 56 | // Force acquire so that user's critical section receives correct values |
| 57 | // from processor that was previously in the user's critical section. |
| 58 | __TBB_load_with_acquire(going); |
| 59 | } |
| 60 | |
| 61 | //! A method to acquire queuing_mutex if it is free |
| 62 | bool queuing_mutex::scoped_lock::try_acquire( queuing_mutex& m ) |
no test coverage detected