signal: replace windows::Event with windows::CtrlBreak (#1331)

* Add a new `windows::CtrlBreak` struct which wil represent a stream of
CTRL_BREAK_EVENT signals on Windows systems
* The `windows::Event` type is no longer publicly accessible and is
replaced by using `CtrlC` or `windows::CtrlBreak`.

[breaking-change]
This commit is contained in:
Ivan Petkov
2019-07-20 10:50:27 -07:00
committed by Carl Lerche
parent 9af07ce208
commit 320a5fdca7
4 changed files with 59 additions and 15 deletions
+6 -1
View File
@@ -20,6 +20,11 @@ use tokio_reactor::Handle;
/// Note that there are a number of caveats listening for signals, and you may
/// wish to read up on the documentation in the `unix` or `windows` module to
/// take a peek.
///
/// Notably, a notification to this process notifies *all* streams listening to
/// this event. Moreover, the notifications **are coalesced** if they aren't processed
/// quickly enough. This means that if two notifications are received back-to-back,
/// then the stream may only receive one item about the two notifications.
#[must_use = "streams do nothing unless polled"]
#[derive(Debug)]
pub struct CtrlC {
@@ -39,7 +44,7 @@ impl CtrlC {
/// process.
///
/// This function binds to reactor specified by `handle`.
pub fn with_handle(handle: &Handle) -> IoFuture<CtrlC> {
pub fn with_handle(handle: &Handle) -> IoFuture<Self> {
Inner::ctrl_c(handle).map_ok(|inner| Self { inner }).boxed()
}
}