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 Thread.sleep(Time::Span) #14715

Merged

Conversation

ysbaddaden
Copy link
Contributor

Suspends the execution of the current thread for a given duration.

This is meant as a system helper only. My use cases are starting a bare thread (without a scheduler or event loop) to execute some operations at regular intervals.

An example is an experiment for RFC 2 of a monitoring thread to collect stacks, to check how long a fiber has been running, and more.

Another example is an in-progress feature for perf-tools that regularly prints runtime information, without impacting or being impacted by the schedulers.

Blocks the current thread for the given duration.
@straight-shoota
Copy link
Member

I suppose this could potentially also be useful for high-precision sleep with sub-millisecond resolution (#6586). At least on Unix systems.

@straight-shoota straight-shoota added this to the 1.13.0 milestone Jun 15, 2024
@straight-shoota straight-shoota changed the title Add Thread.sleep(Time::Span) Add Thread.sleep(Time::Span) Jun 15, 2024
@straight-shoota straight-shoota merged commit bcb5aeb into crystal-lang:master Jun 16, 2024
61 checks passed
@ysbaddaden ysbaddaden deleted the feature/system-thread-sleep branch June 17, 2024 09:13
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