LocalTaskRuntime

Struct LocalTaskRuntime 

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

本地异步任务运行时

Implementations§

Source§

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

Source

pub fn is_running(&self) -> bool

判断当前本地异步任务运行时是否正在运行

Source

pub fn get_id(&self) -> usize

获取当前异步运行时的唯一id

Source

pub fn len(&self) -> usize

获取当前异步运行时任务数量

Source

pub fn spawn<F>(&self, future: F)
where F: Future<Output = O> + 'static,

派发一个指定的异步任务到异步运行时

Source

pub fn send<F>(&self, future: F)
where F: Future<Output = O> + 'static,

线程安全的发送一个异步任务到异步运行时

Source

pub fn poll(&self)

将外部任务队列中的任务移动到内部任务队列

Source

pub fn wait<V: 'static>(&self) -> AsyncWait<V>

挂起当前异步运行时的当前任务,并在指定的其它运行时上派发一个指定的异步任务,等待其它运行时上的异步任务完成后,唤醒当前运行时的当前任务,并返回其它运行时上的异步任务的值

Source

pub fn wait_any<V: 'static>(&self, capacity: usize) -> AsyncWaitAny<V>

挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,其中任意一个任务完成,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成的任务的值将被忽略

Source

pub fn wait_any_callback<V: 'static>( &self, capacity: usize, ) -> AsyncWaitAnyCallback<V>

挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,任务返回后需要通过用户指定的检查回调进行检查,其中任意一个任务检查通过,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成或未检查通过的任务的值将被忽略,如果所有任务都未检查通过,则强制唤醒当前运行时的当前任务

Source

pub fn map_reduce<V: 'static>(&self, capacity: usize) -> AsyncMapReduce<V>

构建用于派发多个异步任务到指定运行时的映射归并,需要指定映射归并的容量

Source

pub fn yield_now(&self) -> LocalBoxFuture<'static, ()>

立即让出当前任务的执行

Source

pub fn pipeline<S, SO, F, FO>( &self, input: S, filter: F, ) -> LocalBoxStream<'static, FO>
where S: Stream<Item = SO> + 'static, SO: 'static, F: FnMut(SO) -> AsyncPipelineResult<FO> + 'static, FO: 'static,

生成一个异步管道,输入指定流,输入流的每个值通过过滤器生成输出流的值

Source

pub fn block_on<F>(&self, future: F) -> IOResult<F::Output>
where F: Future + 'static, <F as Future>::Output: Default + 'static,

阻塞当前线程,并在当前线程内执行指定的异步任务,返回指定异步任务执行后的结果

Source

pub fn close(self) -> bool

关闭异步运行时,返回请求关闭是否成功

Trait Implementations§

Source§

impl<O: Default + 'static> Clone for LocalTaskRuntime<O>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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,