Skip to content

Commit 474c172

Browse files
authored
refactor(signal): runtime agnostic (#797)
1 parent 39ca912 commit 474c172

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ criterion = "0.8.0"
5050
crossbeam-queue = "0.3.8"
5151
flume = { version = "0.12.0", default-features = false }
5252
futures-channel = "0.3.29"
53+
futures-executor = "0.3.30"
5354
futures-rustls = { version = "0.26.0", default-features = false }
5455
futures-util = "0.3.29"
5556
libc = "0.2.175"

compio-io/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ cfg-if = { workspace = true, optional = true }
2020
thiserror = { workspace = true, optional = true }
2121
serde = { version = "1.0.219", optional = true }
2222
serde_json = { version = "1.0.140", optional = true }
23-
bytemuck = { workspace = true, optional = true, features = ["min_const_generics"] }
23+
bytemuck = { workspace = true, optional = true, features = [
24+
"min_const_generics",
25+
] }
2426

2527
[target.'cfg(unix)'.dependencies]
2628
libc = { workspace = true, optional = true }
@@ -35,7 +37,7 @@ compio-net = { workspace = true }
3537
compio-runtime = { workspace = true }
3638
tokio = { workspace = true, features = ["macros", "rt"] }
3739
serde = { version = "1.0.219", features = ["derive"] }
38-
futures-executor = "0.3.30"
40+
futures-executor = { workspace = true }
3941

4042
[features]
4143
default = ["bytes"]

compio-signal/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ synchrony = { workspace = true, features = ["async_flag"] }
2020

2121
# Windows specific dependencies
2222
[target.'cfg(windows)'.dependencies]
23-
compio-driver = { workspace = true }
2423
windows-sys = { workspace = true, features = [
2524
"Win32_Foundation",
2625
"Win32_System_Console",
@@ -32,7 +31,7 @@ libc = { workspace = true }
3231
os_pipe = { workspace = true }
3332

3433
[dev-dependencies]
35-
compio-runtime = { workspace = true }
34+
futures-executor = { workspace = true }
3635

3736
[features]
3837
# Nightly features

compio-signal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! ```rust,no_run
88
//! use compio_signal::ctrl_c;
99
//!
10-
//! # compio_runtime::Runtime::new().unwrap().block_on(async {
10+
//! # futures_executor::block_on(async {
1111
//! ctrl_c().await.unwrap();
1212
//! println!("ctrl-c received!");
1313
//! # })

compio-signal/src/windows.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::sync::LazyLock;
66
use std::sync::OnceLock;
77
use std::{collections::HashMap, io, sync::Mutex};
88

9-
use compio_driver::syscall;
109
#[cfg(not(feature = "lazy_cell"))]
1110
use once_cell::sync::Lazy as LazyLock;
1211
#[cfg(not(feature = "once_cell_try"))]
@@ -41,8 +40,11 @@ unsafe extern "system" fn ctrl_event_handler(ctrltype: u32) -> BOOL {
4140
static INIT: OnceLock<()> = OnceLock::new();
4241

4342
fn init() -> io::Result<()> {
44-
syscall!(BOOL, SetConsoleCtrlHandler(Some(ctrl_event_handler), 1))?;
45-
Ok(())
43+
if unsafe { SetConsoleCtrlHandler(Some(ctrl_event_handler), 1) } != 0 {
44+
Ok(())
45+
} else {
46+
Err(io::Error::last_os_error())
47+
}
4648
}
4749

4850
fn register(ctrltype: u32, e: &Event) -> usize {

0 commit comments

Comments
 (0)