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

Method try_lock

src/bthread/mutex.cpp:1138–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1136}
1137
1138bool FastPthreadMutex::try_lock() {
1139 auto split = (bthread::MutexInternal*)&_futex;
1140 bool lock = !split->locked.exchange(1, butil::memory_order_acquire);
1141 if (lock) {
1142 PTHREAD_MUTEX_SET_OWNER(_owner);
1143 ADD_TLS_PTHREAD_LOCK_COUNT;
1144 }
1145 return lock;
1146}
1147
1148bool FastPthreadMutex::timed_lock(const struct timespec* abstime) {
1149 if (try_lock()) {

Callers 1

Calls 1

exchangeMethod · 0.45

Tested by

no test coverage detected