Skip to main content

RuntimeBuilder

Struct RuntimeBuilder 

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

Runtime builder / 运行时构建器

Provides a fluent API for configuring and building a runtime. 提供用于配置和构建运行时的流畅API。

§Example / 示例

use hiver_runtime::Runtime;

let runtime = Runtime::builder()
    .worker_threads(4)
    .queue_size(512)
    .build()
    .unwrap();

Implementations§

Source§

impl RuntimeBuilder

Source

pub fn new() -> Self

Create a new runtime builder with default configuration 使用默认配置创建新的运行时构建器

Source

pub fn worker_threads(self, count: usize) -> Self

Set the number of worker threads 设置工作线程数量

Source

pub fn queue_size(self, size: usize) -> Self

Set the queue size for the scheduler 设置调度器的队列大小

Source

pub fn thread_name(self, name: impl Into<String>) -> Self

Set the thread name pattern 设置线程名称模式

Source

pub fn driver_type(self, driver_type: DriverType) -> Self

Set the driver type 设置driver类型

Source

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

Set the I/O driver queue depth 设置I/O驱动队列深度

Source

pub fn enable_parking(self, enable: bool) -> Self

Enable or disable thread parking 启用或禁用线程休眠

Source

pub fn park_timeout(self, timeout: Duration) -> Self

Set the park timeout 设置休眠超时

Source

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

Build the runtime 构建运行时

§Errors / 错误

Returns an error if runtime initialization fails. 如果运行时初始化失败则返回错误。

Trait Implementations§

Source§

impl Default for RuntimeBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.