pub struct BasicRuntime { /* private fields */ }Expand description
Non-fork-safe SharedRuntime implementation.
The internal Arc<tokio::runtime::Runtime> is either library-built
(BasicRuntime::new / BasicRuntime::with_worker_threads) or
caller-provided (BasicRuntime::from_handle). The Arc keeps the runtime
alive for the lifetime of this struct even if the caller drops their clone of
the handle.
This type does not implement the fork protocol. If the process forks,
use crate::ForkSafeRuntime instead — or handle the fork at the
outer runtime layer that owns the tokio runtime passed in.
Implementations§
Source§impl BasicRuntime
impl BasicRuntime
Sourcepub fn with_worker_threads(
worker_threads: usize,
) -> Result<Self, SharedRuntimeError>
pub fn with_worker_threads( worker_threads: usize, ) -> Result<Self, SharedRuntimeError>
Creates a new BasicRuntime backed by a library-built multi-thread tokio runtime
with the given number of worker threads.
Sourcepub fn from_handle(runtime: Arc<Runtime>) -> Self
pub fn from_handle(runtime: Arc<Runtime>) -> Self
Creates a new BasicRuntime wrapping a caller-provided runtime.
The runtime is held via Arc, so it stays alive for the lifetime of this struct
even if the caller drops their clone.
Trait Implementations§
Source§impl BlockingRuntime for BasicRuntime
impl BlockingRuntime for BasicRuntime
Source§impl Debug for BasicRuntime
impl Debug for BasicRuntime
Source§fn new() -> Result<Self, SharedRuntimeError>
fn new() -> Result<Self, SharedRuntimeError>
Source§fn spawn_worker<T: Worker + Sync + 'static>(
&self,
worker: T,
restart_on_fork: bool,
) -> Result<WorkerHandle, SharedRuntimeError>
fn spawn_worker<T: Worker + Sync + 'static>( &self, worker: T, restart_on_fork: bool, ) -> Result<WorkerHandle, SharedRuntimeError>
restart_on_fork = true causes ForkSafeRuntime::after_fork_child
to reset and restart it; false drops it without calling shutdown. BasicRuntime
and [LocalRuntime] ignore this flag — they do not implement a fork protocol.Source§async fn shutdown_async(&self)
async fn shutdown_async(&self)
ForkSafeRuntime::shutdown (native only) to also drop the tokio runtime.