A method to acquire queuing_mutex if it is free
| 60 | |
| 61 | //! A method to acquire queuing_mutex if it is free |
| 62 | bool queuing_mutex::scoped_lock::try_acquire( queuing_mutex& m ) |
| 63 | { |
| 64 | __TBB_ASSERT( !this->mutex, "scoped_lock is already holding a mutex"); |
| 65 | |
| 66 | // Must set all fields before the fetch_and_store, because once the |
| 67 | // fetch_and_store executes, *this becomes accessible to other threads. |
| 68 | next = NULL; |
| 69 | going = 0; |
| 70 | |
| 71 | // The CAS must have release semantics, because we are |
| 72 | // "sending" the fields initialized above to other processors. |
| 73 | if( m.q_tail.compare_and_swap<tbb::release>(this, NULL) ) |
| 74 | return false; |
| 75 | |
| 76 | // Force acquire so that user's critical section receives correct values |
| 77 | // from processor that was previously in the user's critical section. |
| 78 | // try_acquire should always have acquire semantic, even if failed. |
| 79 | __TBB_load_with_acquire(going); |
| 80 | mutex = &m; |
| 81 | ITT_NOTIFY(sync_acquired, mutex); |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | //! A method to release queuing_mutex lock |
| 86 | void queuing_mutex::scoped_lock::release( ) |
no test coverage detected