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

Method try_acquire

benchmarks/tbb/queuing_mutex.cpp:62–83  ·  view source on GitHub ↗

A method to acquire queuing_mutex if it is free

Source from the content-addressed store, hash-verified

60
61//! A method to acquire queuing_mutex if it is free
62bool 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
86void queuing_mutex::scoped_lock::release( )

Callers 6

internal_fast_findMethod · 0.45
lookupMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Calls 1

__TBB_load_with_acquireFunction · 0.85

Tested by

no test coverage detected