folly/folly/io/async/HHWheelTimer.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/io/async/HHWheelTimer.h>

#include <cassert>

#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/ScopeGuard.h>
#include <folly/container/BitIterator.h>
#include <folly/io/async/Request.h>
#include <folly/lang/Bits.h>

namespace folly {
/**
 * We want to select the default interval carefully.
 * An interval of 10ms will give us 10ms * WHEEL_SIZE^WHEEL_BUCKETS
 * for the largest timeout possible, or about 497 days.
 *
 * For a lower bound, we want a reasonable limit on local IO, 10ms
 * seems short enough
 *
 * A shorter interval also has CPU implications, less than 1ms might
 * start showing up in cpu perf.  Also, it might not be possible to set
 * tick interval less than 10ms on older kernels.
 */

/*
 * For high res timers:
 * An interval of 200usec will give us 200usec * WHEEL_SIZE^WHEEL_BUCKETS
 * for the largest timeout possible, or about 9 days.
 */

template <class Duration>
int HHWheelTimerBase<Duration>::DEFAULT_TICK_INTERVAL =;

template <class Duration>
HHWheelTimerBase<Duration>::Callback::Callback() = default;

template <class Duration>
HHWheelTimerBase<Duration>::Callback::~Callback() {}

template <class Duration>
void HHWheelTimerBase<Duration>::Callback::setScheduled(
    HHWheelTimerBase* wheel, std::chrono::steady_clock::time_point deadline) {}

template <class Duration>
void HHWheelTimerBase<Duration>::Callback::cancelTimeoutImpl() {}

template <class Duration>
HHWheelTimerBase<Duration>::HHWheelTimerBase(
    folly::TimeoutManager* timeoutMananger,
    Duration intervalDuration,
    AsyncTimeout::InternalEnum internal,
    Duration defaultTimeoutDuration)
    :{}

template <class Duration>
HHWheelTimerBase<Duration>::~HHWheelTimerBase() {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleTimeoutImpl(
    Callback* callback,
    int64_t dueTick,
    int64_t nextTickToProcess,
    int64_t nextTick) {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleTimeout(
    Callback* callback, Duration timeout) {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleTimeout(Callback* callback) {}

template <class Duration>
bool HHWheelTimerBase<Duration>::cascadeTimers(
    int bucket, int tick, const std::chrono::steady_clock::time_point curTime) {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleTimeoutInternal(Duration timeout) {}

template <class Duration>
void HHWheelTimerBase<Duration>::timeoutExpired() noexcept {}

template <class Duration>
size_t HHWheelTimerBase<Duration>::cancelAll() {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleNextTimeout(int64_t nextTick) {}

template <class Duration>
void HHWheelTimerBase<Duration>::scheduleNextTimeout(
    int64_t nextTick, int64_t ticks) {}

template <class Duration>
size_t HHWheelTimerBase<Duration>::cancelTimeoutsFromList(
    CallbackList& timeouts) {}

template <class Duration>
int64_t HHWheelTimerBase<Duration>::calcNextTick() {}

template <class Duration>
int64_t HHWheelTimerBase<Duration>::calcNextTick(
    std::chrono::steady_clock::time_point curTime) {}

// std::chrono::microseconds
template <>
void HHWheelTimerBase<std::chrono::microseconds>::scheduleTimeoutInternal(
    std::chrono::microseconds timeout) {}

// std::chrono::milliseconds
template class HHWheelTimerBase<std::chrono::milliseconds>;

// std::chrono::microseconds
template class HHWheelTimerBase<std::chrono::microseconds>;
} // namespace folly