mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
signal: refactor Windows registrations to be lazy (#1001)
- Use `Handle::default` over `Handle::current` for consistent semantics - Make all `windows::Event` constructors lazily invoke `global_init` so they can be safely constructed off-task - Don't assume the reactor is alive and event registration will be done when calling `global_init` Add windows regression tests. Unfortunately, Windows doesn't have a reliable way of programmatically sending CTRL_C or CTRL_BREAK events to a progress, so the tests can only exercise our internal machinery by invoking the handler that we register with the OS Fixes #999
This commit is contained in:
@@ -53,7 +53,12 @@ fn main() -> Result<(), Box<std::error::Error>> {
|
||||
// Up until now, we haven't really DONE anything, just prepared
|
||||
// now it's time to actually schedule, and thus execute, the stream
|
||||
// on our event loop
|
||||
tokio::runtime::current_thread::block_on_all(future)?;
|
||||
// FIXME(1000): windows uses a global driver task which doesn't terminate
|
||||
// on its own, so if we use block_on_all our application will never exit
|
||||
//tokio::runtime::current_thread::block_on_all(future)?;
|
||||
tokio::runtime::current_thread::Runtime::new()
|
||||
.expect("failed to start runtime on current thread")
|
||||
.block_on(future)?;
|
||||
|
||||
println!("Stream ended, quiting the program.");
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user