Change trylock() to try_lock() in folly::SpinLock to conform to standard Lockable.
authorMaged Michael <magedmichael@fb.com>
Tue, 28 Mar 2017 15:36:31 +0000 (08:36 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 28 Mar 2017 15:37:46 +0000 (08:37 -0700)
Reviewed By: yfeldblum

Differential Revision: D4782707

fbshipit-source-id: 535b42b4f2558cadc78037268d6de81a8bb49840

folly/detail/SpinLockImpl.h
folly/io/async/NotificationQueue.h
folly/test/SpinLockTest.cpp

index ef974e801a913dc8e64d640fdcb553075ae2a8ef..22ba7535a31e6325e9dd5522f61e800cbfe6c45f 100644 (file)
@@ -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;
index 28daf77ae670f618b3a9fa0338eb4c812f9c5674..f27b17f5b98043d74febd1d36c02f7653272cde8 100644 (file)
@@ -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: "
index 7c263c377ed55ae2e0ee83723faa9aaa6a1ae9c1..029e6625bd466c1e398f48897c37fe03b3df69e3 100644 (file)
@@ -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) {