16 auto* next = PollRandomElementFromList(_queue);
60void Scheduler::AdvanceTime()
noexcept {
61 if (_sleep_list.begin()->first >= _time) {
71void Scheduler::WakeUpNeeded()
noexcept {
73 for (
auto it = _sleep_list.begin();
it != _sleep_list.end();
it++) {
74 if (
it->first > _time) {
85void Scheduler::RunLoop() {
86 while (!_queue.
Empty() || !_sleep_list.empty()) {
91 auto* next = GetNext();
130 auto it = _sleep_list.find(
ns);
131 YACLIB_DEBUG(
it == _sleep_list.end(),
"sleep_list for time that is not passed yet isn't found");
132 if (
it->second.Empty()) {
133 _sleep_list.erase(
ns);
bool Empty() const noexcept
void PushBack(Node *node) noexcept
void PushAll(BiList &&other) noexcept
void SetState(FiberState state) noexcept
Id GetId() const noexcept
void Schedule(detail::fiber::FiberBase *fiber)
static void SetTickLength(std::uint32_t tick) noexcept
static detail::fiber::FiberBase::Id GetId()
static void RescheduleCurrent()
std::uint64_t GetTimeNs() const noexcept
void SleepPreemptive(std::uint64_t ns)
static void Set(Scheduler *scheduler) noexcept
static Scheduler * GetScheduler() noexcept
static detail::fiber::FiberBase * Current() noexcept
void Sleep(std::uint64_t ns)
bool IsRunning() const noexcept
#define YACLIB_DEBUG(cond, message)
#define YACLIB_ASSERT(cond)
Node * PollRandomElementFromList(BiList &list)
static std::uint32_t sRandomListPick
void SetRandomListPick(std::uint32_t k) noexcept
std::uint64_t GetRandNumber(std::uint64_t max)
static std::uint32_t sTickLength
static Scheduler * sCurrentScheduler
static thread_local detail::fiber::FiberBase * sCurrent
Contract< V, E > MakeContract()
Creates related future and promise.
std::uint32_t GetFaultSleepTime() noexcept