Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maitake Clock could be a trait if the global clock was double-indirected #488

Open
hawkw opened this issue Oct 13, 2024 · 2 comments
Open

Comments

@hawkw
Copy link
Owner

hawkw commented Oct 13, 2024

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.

@hawkw
Copy link
Owner Author

hawkw commented Oct 13, 2024

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.

@hawkw
Copy link
Owner Author

hawkw commented Oct 25, 2024

alternatively we could do some vtable bullshit instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant