-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose other kqueue filters (#83)
* feat: Expose other kqueue filters * Fix netbsd/openbsd compilation * Build MSRV for FreeBsd/OpenBsd in CI * Only run MSRV BSD builds on Linux * Change API a little + fix netbsd timer * Add inlines + move PollerSealed * rustfmt * Make filter fields public * Fix examples
- Loading branch information
Showing
6 changed files
with
445 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#[cfg(all( | ||
any( | ||
target_os = "macos", | ||
target_os = "ios", | ||
target_os = "tvos", | ||
target_os = "watchos", | ||
target_os = "freebsd", | ||
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "dragonfly", | ||
), | ||
not(polling_test_poll_backend), | ||
))] | ||
mod example { | ||
use polling::os::kqueue::{PollerKqueueExt, Signal}; | ||
use polling::{PollMode, Poller}; | ||
|
||
pub(super) fn main2() { | ||
// Create a poller. | ||
let poller = Poller::new().unwrap(); | ||
|
||
// Register SIGINT in the poller. | ||
let sigint = Signal(libc::SIGINT); | ||
poller.add_filter(sigint, 1, PollMode::Oneshot).unwrap(); | ||
|
||
let mut events = vec![]; | ||
|
||
println!("Press Ctrl+C to exit..."); | ||
|
||
loop { | ||
// Wait for events. | ||
poller.wait(&mut events, None).unwrap(); | ||
|
||
// Process events. | ||
for ev in events.drain(..) { | ||
match ev.key { | ||
1 => { | ||
println!("SIGINT received"); | ||
return; | ||
} | ||
_ => unreachable!(), | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(all( | ||
any( | ||
target_os = "macos", | ||
target_os = "ios", | ||
target_os = "tvos", | ||
target_os = "watchos", | ||
target_os = "freebsd", | ||
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "dragonfly", | ||
), | ||
not(polling_test_poll_backend), | ||
))] | ||
fn main() { | ||
example::main2(); | ||
} | ||
|
||
#[cfg(not(all( | ||
any( | ||
target_os = "macos", | ||
target_os = "ios", | ||
target_os = "tvos", | ||
target_os = "watchos", | ||
target_os = "freebsd", | ||
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "dragonfly", | ||
), | ||
not(polling_test_poll_backend), | ||
)))] | ||
fn main() { | ||
eprintln!("This example is only supported on kqueue-based platforms."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Platform-specific functionality. | ||
#[cfg(all( | ||
any( | ||
target_os = "macos", | ||
target_os = "ios", | ||
target_os = "tvos", | ||
target_os = "watchos", | ||
target_os = "freebsd", | ||
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "dragonfly", | ||
), | ||
not(polling_test_poll_backend), | ||
))] | ||
pub mod kqueue; | ||
|
||
mod __private { | ||
#[doc(hidden)] | ||
pub trait PollerSealed {} | ||
} |
Oops, something went wrong.