Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions folly/synchronization/MicroSpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ struct MicroSpinLock {
void init() noexcept { payload()->store(FREE); }

bool try_lock() noexcept {
bool ret = xchg(LOCKED) == FREE;
bool ret = xchg_acq(LOCKED) == FREE;
annotate_rwlock_try_acquired(
this, annotate_rwlock_level::wrlock, ret, __FILE__, __LINE__);
return ret;
}

void lock() noexcept {
detail::Sleeper sleeper;
while (xchg(LOCKED) != FREE) {
while (xchg_acq(LOCKED) != FREE) {
do {
sleeper.wait();
} while (payload()->load(std::memory_order_relaxed) == LOCKED);
Expand All @@ -98,9 +98,9 @@ struct MicroSpinLock {
return reinterpret_cast<std::atomic<uint8_t>*>(&this->lock_);
}

uint8_t xchg(uint8_t newVal) noexcept {
uint8_t xchg_acq(uint8_t newVal) noexcept {
return std::atomic_exchange_explicit(
payload(), newVal, std::memory_order_acq_rel);
payload(), newVal, std::memory_order_acquire);
}
};
static_assert(
Expand Down