diff options
author | hozan23 <hozan23@karyontech.net> | 2024-06-30 01:13:45 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-06-30 01:13:45 +0200 |
commit | 4dc6ae61c66d2ecedb3dbd519dde89e8afc727a9 (patch) | |
tree | d5ecff0aed228119f3cb6e21f91f4e749456f13b /p2p/examples/shared | |
parent | 5c0abab1b7bf0f2858c451d6f0efc7ca0e138fc6 (diff) |
p2p: remove async-std from dev dependencies & clean up examples
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 { |