Skip to content

Commit

Permalink
prefer FOLLY_SAFE_CHECK in PicoSpinLock
Browse files Browse the repository at this point in the history
Summary: Its code is small.

Reviewed By: Gownta

Differential Revision: D48932192

fbshipit-source-id: 4e9a8d663e705ab59335b9d31bf14374d01eb4fe
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Sep 10, 2023
1 parent 5d211e3 commit cc12ac2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions folly/synchronization/PicoSpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
#include <mutex>
#include <type_traits>

#include <glog/logging.h>

#include <folly/Portability.h>
#include <folly/lang/SafeAssert.h>
#include <folly/synchronization/AtomicRef.h>
#include <folly/synchronization/AtomicUtil.h>
#include <folly/synchronization/SanitizeThread.h>
Expand Down Expand Up @@ -91,7 +90,7 @@ struct PicoSpinLock {
* (This doesn't use a constructor because we want to be a POD.)
*/
void init(IntType initialValue = 0) {
CHECK(!(initialValue & kLockBitMask_));
FOLLY_SAFE_CHECK(!(initialValue & kLockBitMask_));
auto ref = make_atomic_ref(lock_);
auto val = UIntType(initialValue);
ref.store(val, std::memory_order_release);
Expand Down Expand Up @@ -119,7 +118,7 @@ struct PicoSpinLock {
* guaranteed that no other threads may be trying to use this.
*/
void setData(IntType w) {
CHECK(!(w & kLockBitMask_));
FOLLY_SAFE_CHECK(!(w & kLockBitMask_));
auto ref = make_atomic_ref(lock_);
auto val = ref.load(std::memory_order_relaxed);
val = (val & kLockBitMask_) | w;
Expand Down Expand Up @@ -158,7 +157,7 @@ struct PicoSpinLock {
annotate_rwlock_released(
this, annotate_rwlock_level::wrlock, __FILE__, __LINE__);
auto previous = atomic_fetch_reset(ref, Bit, std::memory_order_release);
DCHECK(previous);
FOLLY_SAFE_DCHECK(previous);
}

private:
Expand Down

0 comments on commit cc12ac2

Please sign in to comment.