Struct RuntimeBuilder

Source
pub struct RuntimeBuilder<D> { /* private fields */ }
Expand description

Runtime builder

Implementations§

Source§

impl<T> RuntimeBuilder<T>

Source

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>

Source

pub fn build(self) -> Result<Runtime<IoUringDriver>>

Build the runtime.

Source§

impl RuntimeBuilder<TimeDriver<IoUringDriver>>

Source

pub fn build(self) -> Result<Runtime<TimeDriver<IoUringDriver>>>

Build the runtime.

Source§

impl RuntimeBuilder<LegacyDriver>

Source

pub fn build(self) -> Result<Runtime<LegacyDriver>>

Build the runtime.

Source§

impl RuntimeBuilder<TimeDriver<LegacyDriver>>

Source

pub fn build(self) -> Result<Runtime<TimeDriver<LegacyDriver>>>

Build the runtime.

Source§

impl<D> RuntimeBuilder<D>

Source

pub fn with_entries(self, entries: u32) -> Self

Set io_uring entries, min size is 256 and the default size is 1024.

Source

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>

Source

pub fn build(self) -> Result<FusionRuntime<IoUringDriver, LegacyDriver>>

Build the runtime.

Source§

impl RuntimeBuilder<TimeDriver<FusionDriver>>

Source§

impl<D: TimeWrapable> RuntimeBuilder<D>

Source

pub fn enable_all(self) -> RuntimeBuilder<TimeDriver<D>>

Enable all(currently only timer)

Source

pub fn enable_timer(self) -> RuntimeBuilder<TimeDriver<D>>

Enable timer

Source§

impl<D> RuntimeBuilder<D>

Source

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.

Source

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>

Source§

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.

Auto Trait Implementations§

§

impl<D> Freeze for RuntimeBuilder<D>

§

impl<D> !RefUnwindSafe for RuntimeBuilder<D>

§

impl<D> Send for RuntimeBuilder<D>
where D: Send,

§

impl<D> !Sync for RuntimeBuilder<D>

§

impl<D> Unpin for RuntimeBuilder<D>
where D: Unpin,

§

impl<D> !UnwindSafe for RuntimeBuilder<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.