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

Add Crystal::System::Time.ticks #14620

Conversation

ysbaddaden
Copy link
Contributor

@ysbaddaden ysbaddaden commented May 23, 2024

The first two commits are straightforward. They mostly do a bit of cleanup. Details are in the commit descriptions.

I'm not sure about the third one: it's meant for #14618 where I want the monotonic time as a basic integer, yet can't have it allocate memory (GC may not be initialized) and raising would be an issue (.monotonic may raise on ).

The C functions are guaranteed to never fail since Windows XP. Also
changes the frequency counter to be lazily initialized on demand (when
needed) instead of always initializing it during program bootstrap.
Returns the current time as per the monotonic clock in nanoseconds.
Doesn't fail (i.e. doesn't raise) and doesn't allocate into the GC
HEAP, so we can use it in tight contexts.
src/crystal/system/win32/time.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota added this to the 1.13.0 milestone May 24, 2024
@straight-shoota straight-shoota changed the title Small enhancements to Crystal::System::Time Add Crystal::System::Time.ticks May 24, 2024
@straight-shoota straight-shoota merged commit a30e3d9 into crystal-lang:master May 25, 2024
61 checks passed
@ysbaddaden ysbaddaden deleted the enhancement/crystal-system-time-monotonic branch May 25, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants