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.
32 lines
484 B
C++
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);
|
|
}
|
|
};
|
|
} |