forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to exit the
varlink::listen
loop.
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes varlink/rust#26 Addresses rust-lang#25
- Loading branch information
Showing
8 changed files
with
175 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,4 @@ members = [ | |
"examples/example", | ||
"examples/more", | ||
"examples/ping", | ||
] | ||
|
||
] |
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
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
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