proxygen
|
Classes | |
class | DistributedMutex |
class | Waiter |
class | WakerMetadata |
Functions | |
std::chrono::nanoseconds | time () |
template<typename Type > | |
Type * | extractAddress (std::uintptr_t from) |
std::uint64_t | strip (std::chrono::nanoseconds t) |
std::uint64_t | recover (std::uint64_t from) |
template<typename Waiter > | |
bool | spin (Waiter &waiter) |
template<typename Waiter > | |
void | doFutexWake (Waiter *waiter) |
template<typename Waiter > | |
bool | doFutexWait (Waiter *waiter, Waiter *&next) |
template<typename Waiter > | |
bool | wait (Waiter *waiter, bool shouldSleep, Waiter *&next) |
void | recordTimedWaiterAndClearTimedBit (bool &timedWaiter, std::uintptr_t &previous) |
bool | preempted (std::uint64_t value) |
bool | isSleeper (std::uintptr_t value) |
template<typename Waiter > | |
std::uintptr_t | tryWake (bool publishing, Waiter *waiter, std::uintptr_t value, WakerMetadata metadata, Waiter *&sleepers) |
template<typename Waiter > | |
bool | wake (bool publishing, Waiter &waiter, WakerMetadata metadata, Waiter *&sleepers) |
template<typename Atomic > | |
void | wakeTimedWaiters (Atomic *state, bool timedWaiters) |
template<typename Atomic , typename Proxy , typename Sleepers > | |
bool | tryUnlockClean (Atomic &state, Proxy &proxy, Sleepers sleepers) |
template<typename Atomic , typename Deadline , typename MakeProxy > | |
auto | timedLock (Atomic &state, Deadline deadline, MakeProxy proxy) |
Variables | |
constexpr auto | kUnlocked = std::uintptr_t{0b0} |
constexpr auto | kLocked = std::uintptr_t{0b1} |
constexpr auto | kTimedWaiter = std::uintptr_t{0b10} |
constexpr auto | kUninitialized = std::uint32_t{0b0} |
constexpr auto | kWaiting = std::uint32_t{0b1} |
constexpr auto | kWake = std::uint32_t{0b10} |
constexpr auto | kSkipped = std::uint32_t{0b11} |
constexpr auto | kAboutToWait = std::uint32_t{0b100} |
constexpr auto | kSleeping = std::uint32_t{0b101} |
constexpr auto | kScheduledAwaySpinThreshold = std::chrono::nanoseconds{200} |
constexpr auto | kMaxSpins = 4000 |
bool folly::detail::distributed_mutex::doFutexWait | ( | Waiter * | waiter, |
Waiter *& | next | ||
) |
Definition at line 378 of file DistributedMutex-inl.h.
References doFutexWake(), folly::exchange(), folly::detail::futexWait(), and kAboutToWait.
Referenced by wait().
void folly::detail::distributed_mutex::doFutexWake | ( | Waiter * | waiter | ) |
Definition at line 342 of file DistributedMutex-inl.h.
References folly::detail::futexWake().
Referenced by doFutexWait(), tryUnlockClean(), and folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
Type* folly::detail::distributed_mutex::extractAddress | ( | std::uintptr_t | from | ) |
Zero out the other bits used by the implementation and return just an address from a uintptr_t
Definition at line 199 of file DistributedMutex-inl.h.
References max.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock().
|
inline |
Definition at line 552 of file DistributedMutex-inl.h.
Referenced by tryWake().
|
inline |
Definition at line 541 of file DistributedMutex-inl.h.
References kUninitialized, recover(), strip(), and time().
Referenced by tryWake().
|
inline |
Definition at line 437 of file DistributedMutex-inl.h.
References UNLIKELY.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), and folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
|
inline |
Recover the timestamp value from an integer that has the timestamp encoded in it
Definition at line 224 of file DistributedMutex-inl.h.
Referenced by preempted().
bool folly::detail::distributed_mutex::spin | ( | Waiter & | waiter | ) |
Definition at line 309 of file DistributedMutex-inl.h.
References folly::asm_volatile_pause(), folly::data(), folly::detail::distributed_mutex::Waiter< Atomic >::futex_, kMaxSpins, kSkipped, kWaiting, max, now(), folly::detail::Sleeper::sleep(), strip(), and time().
Referenced by main(), and wait().
|
inline |
Strips the given nanoseconds into only the least significant 56 bits by moving the least significant 56 bits over by 8 zeroing out the bottom 8 bits to be used as a medium of information transfer for the thread wait nodes
Definition at line 215 of file DistributedMutex-inl.h.
References time().
Referenced by upload.MercurialVCS::__init__(), cpp.gmock_class::_GenerateMethods(), cpp.ast.AstBuilder::_GenerateOne(), pump.Output::Append(), upload.VersionControlSystem::CheckForUnknownFiles(), upload.MercurialVCS::GetBaseFile(), upload::GetEmail(), gmock_doctor::main(), preempted(), upload::RealMain(), spin(), fuse_gtest_files::VerifyOutputFile(), pump::WrapCode(), and pump::WrapComment().
|
inline |
Get the time since epoch in nanoseconds
This is faster than std::chrono::steady_clock because it avoids a VDSO access to get the timestamp counter
Note that the hardware timestamp counter on x86, like std::steady_clock is guaranteed to be monotonically increasing - https://c9x.me/x86/html/file_module_x86_id_278.html
Definition at line 190 of file DistributedMutex-inl.h.
References folly::asm_rdtsc().
Referenced by BENCHMARK(), benchmarkGet(), testing::internal::CheckedDowncastToActualType(), cmake_minimum_required(), folly::BucketedTimeSeries< VT, CT >::countRate(), wangle::FilePoller::fileTouchedWithinCondInternal(), TestAsyncTransport::WriteEvent::getCount(), folly::ssl::OpenSSLCertUtils::getDateTimeStr(), proxygen::getDateTimeStr(), folly::BlockingQueue< folly::CPUThreadPoolExecutor::CPUTask >::getNumPriorities(), folly::fibers::SimpleLoopController::loop(), main(), preempted(), folly::rcu_domain< Tag >::retire(), runFairness(), folly::fibers::TimeoutController::runTimeouts(), folly::fibers::TimeoutController::scheduleRun(), QuickTest::SetUp(), spin(), strip(), QuickTest::TearDown(), TEST(), TEST_F(), testing::gmock_matchers_test::TEST_P(), folly::hazptr_domain< DeterministicAtomic >::try_timed_cleanup(), and folly::fibers::LoopController::~LoopController().
auto folly::detail::distributed_mutex::timedLock | ( | Atomic & | state, |
Deadline | deadline, | ||
MakeProxy | proxy | ||
) |
Definition at line 784 of file DistributedMutex-inl.h.
References folly::atomic_wait_until(), folly::data(), and kLocked.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::try_lock_for(), and folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::try_lock_until().
bool folly::detail::distributed_mutex::tryUnlockClean | ( | Atomic & | state, |
Proxy & | proxy, | ||
Sleepers | sleepers | ||
) |
Definition at line 677 of file DistributedMutex-inl.h.
References doFutexWake(), and UNLIKELY.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
std::uintptr_t folly::detail::distributed_mutex::tryWake | ( | bool | publishing, |
Waiter * | waiter, | ||
std::uintptr_t | value, | ||
WakerMetadata | metadata, | ||
Waiter *& | sleepers | ||
) |
Definition at line 557 of file DistributedMutex-inl.h.
References isSleeper(), cpp.ast::next(), and preempted().
Referenced by wake().
bool folly::detail::distributed_mutex::wait | ( | Waiter * | waiter, |
bool | shouldSleep, | ||
Waiter *& | next | ||
) |
Definition at line 429 of file DistributedMutex-inl.h.
References doFutexWait(), and spin().
Referenced by burn(), MultiFilePollerTest::delayedWrite(), folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), folly::Future< folly::folly::Unit >::onError(), folly::Subprocess::readChildErrorPipe(), folly::Subprocess::returnCode(), folly::SemiFuture< T >::SemiFuture(), folly::Subprocess::spawn(), TEST(), TEST_F(), testTryReadUntil(), testTryWriteUntil(), and folly::Subprocess::waitChecked().
bool folly::detail::distributed_mutex::wake | ( | bool | publishing, |
Waiter & | waiter, | ||
WakerMetadata | metadata, | ||
Waiter *& | sleepers | ||
) |
Definition at line 642 of file DistributedMutex-inl.h.
References current, cpp.ast::next(), tryWake(), folly::value(), and folly::detail::distributed_mutex::WakerMetadata::waker_.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
void folly::detail::distributed_mutex::wakeTimedWaiters | ( | Atomic * | state, |
bool | timedWaiters | ||
) |
Definition at line 670 of file DistributedMutex-inl.h.
References folly::atomic_notify_one(), and UNLIKELY.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
constexpr auto folly::detail::distributed_mutex::kAboutToWait = std::uint32_t{0b100} |
Definition at line 88 of file DistributedMutex-inl.h.
Referenced by doFutexWait(), and folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock().
constexpr auto folly::detail::distributed_mutex::kLocked = std::uintptr_t{0b1} |
Definition at line 54 of file DistributedMutex-inl.h.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), timedLock(), and folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock().
constexpr auto folly::detail::distributed_mutex::kMaxSpins = 4000 |
Definition at line 116 of file DistributedMutex-inl.h.
Referenced by spin().
constexpr auto folly::detail::distributed_mutex::kScheduledAwaySpinThreshold = std::chrono::nanoseconds{200} |
Definition at line 113 of file DistributedMutex-inl.h.
constexpr auto folly::detail::distributed_mutex::kSkipped = std::uint32_t{0b11} |
Definition at line 85 of file DistributedMutex-inl.h.
Referenced by spin().
constexpr auto folly::detail::distributed_mutex::kSleeping = std::uint32_t{0b101} |
Definition at line 107 of file DistributedMutex-inl.h.
constexpr auto folly::detail::distributed_mutex::kTimedWaiter = std::uintptr_t{0b10} |
Definition at line 68 of file DistributedMutex-inl.h.
constexpr auto folly::detail::distributed_mutex::kUninitialized = std::uint32_t{0b0} |
Definition at line 76 of file DistributedMutex-inl.h.
Referenced by folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), and preempted().
constexpr auto folly::detail::distributed_mutex::kUnlocked = std::uintptr_t{0b0} |
Definition at line 47 of file DistributedMutex-inl.h.
constexpr auto folly::detail::distributed_mutex::kWaiting = std::uint32_t{0b1} |
Definition at line 79 of file DistributedMutex-inl.h.
Referenced by spin().
constexpr auto folly::detail::distributed_mutex::kWake = std::uint32_t{0b10} |
Definition at line 81 of file DistributedMutex-inl.h.