https://github.com/zduny/interruptor
Collection of functions generating Unix process signal receivers for use in the Crossbeam Channel select! macro.
https://github.com/zduny/interruptor
channels concurrency rust signal
Last synced: 4 months ago
JSON representation
Collection of functions generating Unix process signal receivers for use in the Crossbeam Channel select! macro.
- Host: GitHub
- URL: https://github.com/zduny/interruptor
- Owner: zduny
- License: apache-2.0
- Created: 2021-11-03T16:22:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-14T14:19:07.000Z (over 2 years ago)
- Last Synced: 2024-04-24T09:17:34.712Z (about 2 years ago)
- Topics: channels, concurrency, rust, signal
- Language: Rust
- Homepage: https://docs.rs/interruptor/
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# interruptor
[](https://github.com/zduny/interruptor/actions)
[](https://crates.io/crates/interruptor)
[](https://docs.rs/interruptor)
Collection of functions generating Unix process signal receivers
for use in the [Crossbeam Channel](https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel) `select!` macro.
## example
```rust
use std::time::Duration;
use crossbeam_channel::{select, tick};
use interruptor::interruption_or_termination;
fn main() {
let tick = tick(Duration::from_secs(1));
let stop = interruption_or_termination();
loop {
select! {
recv(tick) -> _ => println!("Running!"),
recv(stop) -> _ => break,
}
};
}
```
## see also
[Crossbeam](https://github.com/crossbeam-rs/crossbeam)
[Crossbeam Channel](https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel)