LocalTaskRunner

Struct LocalTaskRunner 

Source
pub struct LocalTaskRunner<O: Default + 'static = ()>(/* private fields */);
Expand description

本地异步任务执行器

Implementations§

Source§

impl<O: Default + 'static> LocalTaskRunner<O>

Source

pub fn new() -> Self

构建本地异步任务执行器

Source

pub fn with_poll(poller: Arc<Poller>) -> Self

构建一个指定了Poller的本地异步任务执行器 注意当异步任务执行器在运行时,外部不允许使用wait方法

Source

pub fn is_with_polling(&self) -> bool

判断是指定使用Poll

Source

pub fn get_runtime(&self) -> LocalTaskRuntime<O>

获取当前本地异步任务执行器的运行时

Source

pub fn startup( self, thread_name: &str, thread_stack_size: usize, ) -> LocalTaskRuntime<O>

启动工作者异步任务执行器

Source

pub fn startup_with_poll( self, thread_name: &str, thread_stack_size: usize, try_count: usize, timeout: Option<Duration>, ) -> LocalTaskRuntime<O>

启动设置了Poller的工作者异步任务执行器

Source

pub fn poll(&self)

将外部任务队列中的任务移动到内部任务队列 注意应该在执行run_once之前调用

Source

pub fn run_once(&self)

运行一次本地异步任务执行器

Source

pub fn try_sleep( &self, try_count: usize, timeout: Option<Duration>, ) -> IOResult<Option<usize>>

尝试休眠当前推动运行时的线程,并在派发新任务或休眠超时后唤醒 返回Some表示还需要至少多少次尝试以后才可能休眠 注意休眠只在设置了Poller后有效,且在执行run_once后调用

Source

pub fn into_local(self) -> LocalTaskRuntime<O>

转换为本地异步任务运行时

Trait Implementations§

Source§

impl<O: Default + 'static> Send for LocalTaskRunner<O>

Source§

impl<O: Default + 'static> !Sync for LocalTaskRunner<O>

Auto Trait Implementations§

§

impl<O> Freeze for LocalTaskRunner<O>

§

impl<O = ()> !RefUnwindSafe for LocalTaskRunner<O>

§

impl<O> Unpin for LocalTaskRunner<O>

§

impl<O = ()> !UnwindSafe for LocalTaskRunner<O>

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ThreadSend for T
where T: Send,