diff options
Diffstat (limited to 'p2p/examples/shared')
| -rw-r--r-- | p2p/examples/shared/mod.rs | 13 | 
1 files changed, 12 insertions, 1 deletions
diff --git a/p2p/examples/shared/mod.rs b/p2p/examples/shared/mod.rs index 0e8079c..8c00446 100644 --- a/p2p/examples/shared/mod.rs +++ b/p2p/examples/shared/mod.rs @@ -1,8 +1,19 @@ -use std::{num::NonZeroUsize, sync::Arc, thread}; +use std::{io, num::NonZeroUsize, sync::Arc, thread}; +use blocking::unblock;  use easy_parallel::Parallel;  use smol::{channel, future, future::Future, Executor}; +#[allow(dead_code)] +pub async fn read_line_async() -> Result<String, io::Error> { +    unblock(|| { +        let mut input = String::new(); +        std::io::stdin().read_line(&mut input)?; +        Ok(input) +    }) +    .await +} +  /// Returns an estimate of the default amount of parallelism a program should use.  /// see `std::thread::available_parallelism`  pub fn available_parallelism() -> usize {  | 
