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

signal: expose CtrlC stream on windows (closes #3178) #3186

Merged
merged 2 commits into from Nov 27, 2020

Conversation

niklasf
Copy link
Contributor

@niklasf niklasf commented Nov 27, 2020

Motivation

When continuously handling Ctrl+C using tokio::signal::ctrl_c() in a loop, the handler gets registered and deregistered on each iteration. It is useful to instead have an infinite stream of events. This is already possible with signals on Unix and tokio::signal::windows::ctrl_break() on Windows, but tokio::signal::windows::ctrl_c() is currently private.

Solution

  • Make a future-proofed version of ctrl_c() public, analogous to the already public ctrl_break().
  • Stop referring to the private type tokio::signal::windows::Event in the module documentation. Exposing Event would be an alternative solution here, but the chosen approach seems more consistent with the existing API.

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-signal Module: tokio/signal labels Nov 27, 2020
* Make tokio::signal::windows::ctrl_c() public.
* Stop referring to private tokio::signal::windows::Event in module
  documentation.
niklasf added a commit to lichess-org/fishnet that referenced this pull request Nov 27, 2020
Copy link
Member

@ipetkov ipetkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @niklasf 🎉

tokio/src/signal/windows.rs Outdated Show resolved Hide resolved
@ipetkov ipetkov merged commit 4912943 into tokio-rs:master Nov 27, 2020
@niklasf
Copy link
Contributor Author

niklasf commented Nov 27, 2020

Thanks for the fast turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-signal Module: tokio/signal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants