maitake `Clock` could be a trait if the global clock was double-indirected
Opened this issue · 2 comments
originally, i wanted Clock
to be a trait rather than a struct, but that fell apart because i really wanted the global timer to live in a single AtomicPtr
, so it couldn't be generic. but, whilst talking to @iximeow about Totally Unrelated Subjects, it occurred to me that if the timer just held onto a &'static dyn Clock
, and the global timer was an AtomicPtr<Timer>
, you could have a trait based clock. the downside is just that now the clock is double indirected from the timer, which is kinda sad.
this would also let you make the timer generic over the clock's lifetime, allowing you to have a borrowed clock on the stack. in practice, there are basically no valid civilian uses for this technology, but it might make the unit tests slightly nicer.
alternatively we could do some vtable bullshit instead.