mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
23 lines
373 B
C++
23 lines
373 B
C++
#include "clock.h"
|
|
|
|
clock * clock::s_instance = nullptr;
|
|
|
|
clock::clock(uint64_t rate, clock::source source_func, void *data) :
|
|
m_rate(rate),
|
|
m_data(data),
|
|
m_source(source_func)
|
|
{
|
|
// TODO: make this atomic
|
|
if (s_instance == nullptr)
|
|
s_instance = this;
|
|
update();
|
|
}
|
|
|
|
void
|
|
clock::spinwait(uint64_t us) const
|
|
{
|
|
uint64_t when = value() + us;
|
|
while (value() < when);
|
|
}
|
|
|