diff options
author | hozan23 <hozan23@proton.me> | 2023-12-02 05:10:33 +0300 |
---|---|---|
committer | hozan23 <hozan23@proton.me> | 2023-12-02 05:10:33 +0300 |
commit | 8cdc44b24724acf7dd458e59f5ceed4af04574be (patch) | |
tree | 1e0aad5a905508c54f7d9be4d4b800b7e8f7d532 /core/src/executor.rs | |
parent | 5111a3d5749625c3d8e26a24a5a32c4da58f18d3 (diff) |
Ensure uniform usage of the name `karyon` across all files
Diffstat (limited to 'core/src/executor.rs')
-rw-r--r-- | core/src/executor.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/core/src/executor.rs b/core/src/executor.rs deleted file mode 100644 index 136f6ea..0000000 --- a/core/src/executor.rs +++ /dev/null @@ -1,28 +0,0 @@ - - -/// Returns an estimate of the default amount of parallelism a program should use. -/// see `std::thread::available_parallelism` -fn available_parallelism() -> usize { - thread::available_parallelism() - .map(NonZeroUsize::get) - .unwrap_or(1) -} - -/// Run a multi-threaded executor -pub fn run_executor<T>(main_future: impl Future<Output = T>, ex: Executor<'_>) { - let (signal, shutdown) = channel::unbounded::<()>(); - - let num_threads = available_parallelism(); - - Parallel::new() - .each(0..(num_threads), |_| { - future::block_on(ex.run(shutdown.recv())) - }) - // Run the main future on the current thread. - .finish(|| { - future::block_on(async { - main_future.await; - drop(signal); - }) - }); -} |