28 using std::chrono::milliseconds;
54 std::chrono::milliseconds timeout) {
66 wheel_->AsyncTimeout::cancelTimeout();
80 std::chrono::milliseconds intervalMS,
82 std::chrono::milliseconds defaultTimeoutMS)
106 cb->callbackCanceled();
113 std::chrono::milliseconds timeout) {
137 due = diff + nextTick;
141 list->push_back(*callback);
146 std::chrono::milliseconds timeout) {
167 <<
"Default timeout was not initialized";
174 while (!cbs.empty()) {
175 auto* cb = &cbs.front();
190 auto isDestroyed =
false;
206 while (lastTick_ < nextTick) {
214 while (!cbs->empty()) {
215 auto* cb = &cbs->front();
233 cb->wheel_ =
nullptr;
234 cb->expiration_ = {};
236 cb->timeoutExpired();
253 auto buckets = std::make_unique<CallbackList[]>(maxBuckets);
254 size_t countBuckets = 0;
256 for (
auto& bucket : tick) {
257 if (bucket.empty()) {
260 count += bucket.size();
261 std::swap(bucket, buckets[countBuckets++]);
268 for (
size_t i = 0;
i < countBuckets; ++
i) {
269 auto& bucket = buckets[
i];
270 while (!bucket.empty()) {
271 auto& cb = bucket.front();
273 cb.callbackCanceled();
290 tick =
WHEEL_SIZE - ((nextTick - 1) & WHEEL_MASK);
292 tick = std::distance(bi + (nextTick & WHEEL_MASK), it) + 1;
static constexpr unsigned int WHEEL_MASK
void timeoutExpired() noexceptoverride
BitIterator< BaseIter > findFirstSet(BitIterator< BaseIter >, BitIterator< BaseIter >)
static constexpr int WHEEL_BUCKETS
static constexpr int WHEEL_BITS
BitIterator< BaseIter > makeBitIterator(const BaseIter &iter)
static constexpr uint32_t LARGEST_SLOT
std::vector< std::size_t > bitmap_
—— Concurrent Priority Queue Implementation ——
static int DEFAULT_TICK_INTERVAL
requires E e noexcept(noexcept(s.error(std::move(e))))
HHWheelTimer(folly::TimeoutManager *timeoutManager, std::chrono::milliseconds intervalMS=std::chrono::milliseconds(DEFAULT_TICK_INTERVAL), AsyncTimeout::InternalEnum internal=AsyncTimeout::InternalEnum::NORMAL, std::chrono::milliseconds defaultTimeoutMS=std::chrono::milliseconds(-1))
void scheduleTimeout(Callback *callback, std::chrono::milliseconds timeout)
std::chrono::steady_clock::time_point startTime_
CallbackList buckets_[WHEEL_BUCKETS][WHEEL_SIZE]
static std::shared_ptr< RequestContext > saveContext()
std::shared_ptr< RequestContext > requestContext_
void setScheduled(HHWheelTimer *wheel, std::chrono::milliseconds)
Encoder::MutableCompressedList list
void scheduleTimeoutImpl(Callback *callback, std::chrono::milliseconds timeout)
static constexpr unsigned int WHEEL_SIZE
virtual std::chrono::steady_clock::time_point getCurTime()
std::chrono::steady_clock::time_point expiration_
bool * processingCallbacksGuard_
std::chrono::milliseconds defaultTimeout_
void scheduleNextTimeout()
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
uint64_t diff(uint64_t a, uint64_t b)
int64_t timeToWheelTicks(std::chrono::milliseconds t)
bool scheduleTimeout(uint32_t milliseconds)
std::size_t count() const
Callback::List CallbackList
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
bool cascadeTimers(int bucket, int tick)
std::chrono::milliseconds interval_
std::chrono::steady_clock::time_point getCurTime()