Files
snmalloc/src/pal/pal_timer_default.h
Matthew Parkinson 20a114cb62 Add a timer to the PAL
This adds a way to periodically pool the PAL to see if any timers have
expired.  Timers can be used to periodically provide callbacks to the
rest of snmalloc.
2021-10-28 14:28:36 +01:00

32 lines
484 B
C++

#pragma once
#include "pal_consts.h"
#include "pal_ds.h"
#include <chrono>
namespace snmalloc
{
template<typename PalTime>
class PalTimerDefaultImpl
{
inline static PalTimer timers{};
public:
static uint64_t time_in_ms()
{
auto time = PalTime::internal_time_in_ms();
// Process timers
timers.check(time);
return time;
}
static void register_timer(PalTimerObject* timer)
{
timers.register_timer(timer);
}
};
}