Open hawkw opened 1 month ago
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.
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 singleAtomicPtr
, 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 anAtomicPtr<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.