MCPcopy Create free account
hub / github.com/apache/brpc / mutex_trylock_impl

Function mutex_trylock_impl

src/bthread/mutex.cpp:1041–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1039#endif // BRPC_DEBUG_LOCK
1040
1041inline int mutex_trylock_impl(bthread_mutex_t* m) {
1042 MutexInternal* split = (MutexInternal*)m->butex;
1043 if (!split->locked.exchange(1, butil::memory_order_acquire)) {
1044 BTHREAD_MUTEX_SET_OWNER;
1045 return 0;
1046 }
1047 return EBUSY;
1048}
1049
1050const int MAX_SPIN_ITER = 4;
1051

Callers 2

bthread_mutex_trylockFunction · 0.85
bthread_mutex_lock_implFunction · 0.85

Calls 1

exchangeMethod · 0.45

Tested by

no test coverage detected