mpd/src/event/CoarseTimerEvent.cxx
2023-03-06 14:59:48 +01:00

32 lines
512 B
C++

// SPDX-License-Identifier: BSD-2-Clause
// Copyright CM4all GmbH
// author: Max Kellermann <mk@cm4all.com>
#include "CoarseTimerEvent.hxx"
#include "Loop.hxx"
void
CoarseTimerEvent::Schedule(Event::Duration d) noexcept
{
Cancel();
due = loop.SteadyNow() + d;
loop.Insert(*this);
}
void
CoarseTimerEvent::ScheduleEarlier(Event::Duration d) noexcept
{
const auto new_due = loop.SteadyNow() + d;
if (IsPending()) {
if (new_due >= due)
return;
Cancel();
}
due = new_due;
loop.Insert(*this);
}