bolar_2 backup
This commit is contained in:
28
main/schedule/reminder_schedule.h
Normal file
28
main/schedule/reminder_schedule.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace borla {
|
||||
|
||||
class ReminderSchedule final {
|
||||
public:
|
||||
static constexpr size_t kCapacity = 16;
|
||||
|
||||
bool Add(uint64_t deadline_ms);
|
||||
void CancelAll();
|
||||
bool CancelNext();
|
||||
size_t PopDue(uint64_t now_ms);
|
||||
size_t count() const { return count_; }
|
||||
uint64_t next_deadline_ms() const
|
||||
{
|
||||
return count_ == 0 ? 0 : deadlines_[0];
|
||||
}
|
||||
|
||||
private:
|
||||
size_t count_ = 0;
|
||||
std::array<uint64_t, kCapacity> deadlines_{};
|
||||
};
|
||||
|
||||
} // namespace borla
|
||||
Reference in New Issue
Block a user