Commit cfb40f4e authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

Change trylock() to try_lock() in folly::SpinLock to conform to standard Lockable.

Reviewed By: yfeldblum

Differential Revision: D4782707

fbshipit-source-id: 535b42b4f2558cadc78037268d6de81a8bb49840
parent 43a79f74
......@@ -45,7 +45,7 @@ class SpinLockMslImpl {
FOLLY_ALWAYS_INLINE void unlock() const {
lock_.unlock();
}
FOLLY_ALWAYS_INLINE bool trylock() const {
FOLLY_ALWAYS_INLINE bool try_lock() const {
return lock_.try_lock();
}
private:
......@@ -70,7 +70,7 @@ class SpinLockAppleImpl {
FOLLY_ALWAYS_INLINE void unlock() const {
OSSpinLockUnlock(&lock_);
}
FOLLY_ALWAYS_INLINE bool trylock() const {
FOLLY_ALWAYS_INLINE bool try_lock() const {
return OSSpinLockTry(&lock_);
}
private:
......@@ -107,7 +107,7 @@ class SpinLockPthreadImpl {
int rc = pthread_spin_unlock(&lock_);
checkPosixError(rc, "error unlocking spinlock");
}
FOLLY_ALWAYS_INLINE bool trylock() const {
FOLLY_ALWAYS_INLINE bool try_lock() const {
int rc = pthread_spin_trylock(&lock_);
if (rc == 0) {
return true;
......@@ -143,7 +143,7 @@ class SpinLockPthreadMutexImpl {
int rc = pthread_mutex_unlock(&lock_);
checkPosixError(rc, "error unlocking mutex");
}
FOLLY_ALWAYS_INLINE bool trylock() const {
FOLLY_ALWAYS_INLINE bool try_lock() const {
int rc = pthread_mutex_trylock(&lock_);
if (rc == 0) {
return true;
......
......@@ -457,7 +457,7 @@ class NotificationQueue {
NotificationQueue& operator=(NotificationQueue const &) = delete;
inline bool checkQueueSize(size_t maxSize, bool throws=true) const {
DCHECK(0 == spinlock_.trylock());
DCHECK(0 == spinlock_.try_lock());
if (maxSize > 0 && queue_.size() >= maxSize) {
if (throws) {
throw std::overflow_error("unable to add message to NotificationQueue: "
......
......@@ -72,7 +72,7 @@ void trylockTestThread(TryLockState<LOCK>* state, size_t count) {
break;
}
bool ret = state->lock2.trylock();
bool ret = state->lock2.try_lock();
EXPECT_NE(state->locked, ret);
if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment