pub struct RuntimeBuilder<D> { /* private fields */ }
Expand description
Runtime builder
Implementations§
Source§impl<T> RuntimeBuilder<T>
impl<T> RuntimeBuilder<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a default runtime builder.
§Note
When the sync feature is enabled, the default behavior of [monoio::blocking::BlockingStrategy] is to execute tasks on the local thread. In other words, there is no thread pool involved—all blocking I/O operations and heavy computations will block the current thread.
Source§impl RuntimeBuilder<IoUringDriver>
impl RuntimeBuilder<IoUringDriver>
Sourcepub fn build(self) -> Result<Runtime<IoUringDriver>>
pub fn build(self) -> Result<Runtime<IoUringDriver>>
Build the runtime.
Source§impl RuntimeBuilder<TimeDriver<IoUringDriver>>
impl RuntimeBuilder<TimeDriver<IoUringDriver>>
Sourcepub fn build(self) -> Result<Runtime<TimeDriver<IoUringDriver>>>
pub fn build(self) -> Result<Runtime<TimeDriver<IoUringDriver>>>
Build the runtime.
Source§impl RuntimeBuilder<LegacyDriver>
impl RuntimeBuilder<LegacyDriver>
Sourcepub fn build(self) -> Result<Runtime<LegacyDriver>>
pub fn build(self) -> Result<Runtime<LegacyDriver>>
Build the runtime.
Source§impl RuntimeBuilder<TimeDriver<LegacyDriver>>
impl RuntimeBuilder<TimeDriver<LegacyDriver>>
Sourcepub fn build(self) -> Result<Runtime<TimeDriver<LegacyDriver>>>
pub fn build(self) -> Result<Runtime<TimeDriver<LegacyDriver>>>
Build the runtime.
Source§impl<D> RuntimeBuilder<D>
impl<D> RuntimeBuilder<D>
Sourcepub fn with_entries(self, entries: u32) -> Self
pub fn with_entries(self, entries: u32) -> Self
Set io_uring entries, min size is 256 and the default size is 1024.
Sourcepub fn uring_builder(self, urb: Builder) -> Self
pub fn uring_builder(self, urb: Builder) -> Self
Replaces the default io_uring::Builder
, which controls the settings for the
inner io_uring
API.
Refer to the io_uring::Builder
documentation for all the supported methods.
Source§impl RuntimeBuilder<FusionDriver>
impl RuntimeBuilder<FusionDriver>
Sourcepub fn build(self) -> Result<FusionRuntime<IoUringDriver, LegacyDriver>>
pub fn build(self) -> Result<FusionRuntime<IoUringDriver, LegacyDriver>>
Build the runtime.
Source§impl RuntimeBuilder<TimeDriver<FusionDriver>>
impl RuntimeBuilder<TimeDriver<FusionDriver>>
Sourcepub fn build(
self,
) -> Result<FusionRuntime<TimeDriver<IoUringDriver>, TimeDriver<LegacyDriver>>>
pub fn build( self, ) -> Result<FusionRuntime<TimeDriver<IoUringDriver>, TimeDriver<LegacyDriver>>>
Build the runtime.
Source§impl<D: TimeWrapable> RuntimeBuilder<D>
impl<D: TimeWrapable> RuntimeBuilder<D>
Sourcepub fn enable_all(self) -> RuntimeBuilder<TimeDriver<D>>
pub fn enable_all(self) -> RuntimeBuilder<TimeDriver<D>>
Enable all(currently only timer)
Sourcepub fn enable_timer(self) -> RuntimeBuilder<TimeDriver<D>>
pub fn enable_timer(self) -> RuntimeBuilder<TimeDriver<D>>
Enable timer
Source§impl<D> RuntimeBuilder<D>
impl<D> RuntimeBuilder<D>
Sourcepub fn attach_thread_pool(
self,
tp: Box<dyn ThreadPool + Send + 'static>,
) -> Self
pub fn attach_thread_pool( self, tp: Box<dyn ThreadPool + Send + 'static>, ) -> Self
Attach thread pool, this will overwrite blocking strategy.
All spawn_blocking
will be executed on given thread pool.
Sourcepub fn with_blocking_strategy(self, strategy: BlockingStrategy) -> Self
pub fn with_blocking_strategy(self, strategy: BlockingStrategy) -> Self
Set blocking strategy, this will overwrite thread pool setting.
If BlockingStrategy::Panic
is used, it will panic if spawn_blocking
on this thread.
If BlockingStrategy::ExecuteLocal
is used, it will execute with current thread, and may
cause tasks high latency.
Attaching a thread pool is recommended if spawn_blocking
will be used.
Trait Implementations§
Source§impl<T> Default for RuntimeBuilder<T>
impl<T> Default for RuntimeBuilder<T>
Source§fn default() -> Self
fn default() -> Self
Create a default runtime builder.
§Note
When the sync feature is enabled, the default behavior of [monoio::blocking::BlockingStrategy] is to execute tasks on the local thread. In other words, there is no thread pool involved—all blocking I/O operations and heavy computations will block the current thread.