69 template <
typename IdleTime = std::chrono::steady_clock::duration>
71 IdleTime
const& idleTimeout =
72 defaultIdleTimeout.
load(std::memory_order_acquire),
73 float timeoutVariationFrac = 0.5) {
74 if (idleTimeout <= IdleTime::zero() || timeoutVariationFrac <= 0) {
85 auto extraFrac = timeoutVariationFrac /
87 auto tics =
uint64_t(idleTimeout.count() * (1 + extraFrac));
88 return IdleTime(tics);
101 typename IdleTime = std::chrono::steady_clock::duration>
106 IdleTime
const& idleTimeout =
107 defaultIdleTimeout.
load(std::memory_order_acquire),
109 float timeoutVariationFrac = 0.5) {
119 timeoutVariationFrac)) {
124 return futexWait(&fut, expected, waitMask);
138 typename IdleTime = std::chrono::steady_clock::duration>
142 Deadline
const& deadline,
144 IdleTime
const& idleTimeout =
145 defaultIdleTimeout.
load(std::memory_order_acquire),
147 float timeoutVariationFrac = 0.5) {
157 timeoutVariationFrac)) {
166 template <
typename Futex,
typename Deadline,
typename IdleTime>
171 Deadline
const& deadline,
173 IdleTime idleTimeout,
174 size_t stackToRetain,
175 float timeoutVariationFrac) {
177 if (idleTimeout < IdleTime::zero()) {
183 if (idleTimeout > IdleTime::zero()) {
188 if (idleTimeout > IdleTime::zero()) {
190 if (idleDeadline < deadline) {
static FutexResult futexWaitUntil(Futex &fut, uint32_t expected, Deadline const &deadline, uint32_t waitMask=-1, IdleTime const &idleTimeout=defaultIdleTimeout.load(std::memory_order_acquire), size_t stackToRetain=kDefaultStackToRetain, float timeoutVariationFrac=0.5)
static void unmapUnusedStack(size_t retain=kDefaultStackToRetain)
static FutexResult futexWait(Futex &fut, uint32_t expected, uint32_t waitMask=-1, IdleTime const &idleTimeout=defaultIdleTimeout.load(std::memory_order_acquire), size_t stackToRetain=kDefaultStackToRetain, float timeoutVariationFrac=0.5)
static IdleTime getVariationTimeout(IdleTime const &idleTimeout=defaultIdleTimeout.load(std::memory_order_acquire), float timeoutVariationFrac=0.5)
std::chrono::steady_clock::time_point now()
Atom< std::uint32_t > Futex
T load(std::memory_order mo=std::memory_order_seq_cst) const noexcept
—— Concurrent Priority Queue Implementation ——
FutexResult futexWait(const Futex *futex, uint32_t expected, uint32_t waitMask)
static bool futexWaitPreIdle(FutexResult &_ret, Futex &fut, uint32_t expected, Deadline const &deadline, uint32_t waitMask, IdleTime idleTimeout, size_t stackToRetain, float timeoutVariationFrac)
size_t hash_combine(const T &t, const Ts &...ts) noexcept(noexcept(hash_combine_generic(StdHasher{}, t, ts...)))
FutexResult futexWaitUntil(const Futex *futex, uint32_t expected, std::chrono::time_point< Clock, Duration > const &deadline, uint32_t waitMask)
uint64_t twang_mix64(uint64_t key) noexcept
uint64_t getCurrentThreadID()
static AtomicStruct< std::chrono::steady_clock::duration > defaultIdleTimeout
static void flushLocalMallocCaches()