Skip to main content

TaskFactory

Struct TaskFactory 

pub struct TaskFactory<S: Schedule, N: TaskNotifier> { /* private fields */ }
Expand description

实现者持有的创建能力;普通运行时(runtime)不向用户返回本对象。 Clone保持原服务身份。仅新建构造分配RuntimeId,不接受外部指定原身份。

Implementations§

§

impl<S: Schedule, N: TaskNotifier> TaskFactory<S, N>

pub fn try_new( schedule: S, notifier: N, queue_support: QueueSupport, ) -> Result<Self>

准备同一服务的创建工厂(factory),分配不复用的RuntimeId并保存传入能力。 失败返回原报告(Report),不创建任务(Task)、提交业务、启动服务或线程(thread)。

pub fn runtime_id(&self) -> RuntimeId

读取同一原逻辑服务的身份;不赋予来源管理或执行权限。

pub fn submit( &self, task: UnsubmittedTask, mode: SubmissionMode, push: impl FnOnce(Runnable) -> RawResult<(), (Runnable, SubmitErrorKind)>, ) -> RawResult<(), SubmitError>

同源提交能力;只有持有原工厂才可从待提交值交出Runnable给来源实现。 回调(callback)明确拒绝时必须返还同一原值,不接纳、不poll、不取消。

§

impl<S: Schedule + Clone, N: TaskNotifier> TaskFactory<S, N>

pub fn create<F, M>( &self, future: F, config: TaskConfig<M>, ) -> RawResult<(UnsubmittedTask, TaskHandle<N, F::Output, M>), CreateError<F, M>>
where F: Future + Send + 'static, F::Output: Send + 'static, M: Send + Sync + 'static,

使用指定配置创建;返回唯一待提交值与结果句柄(handle),不隐式派发。

pub fn create_local<F, M>( &self, owner: &TaskThread, future: F, config: TaskConfig<M>, ) -> RawResult<(UnsubmittedTask, TaskHandle<N, F::Output, M, LocalOutput>), CreateError<F, M>>
where F: Future + 'static, F::Output: 'static, M: Send + Sync + 'static,

使用指定配置和原TaskThread本地创建;不依赖当前公共环境,不隐式接纳或提交。

pub fn with_notifier<N2: TaskNotifier>( &self, notifier: N2, ) -> TaskFactory<S, N2>

保留原服务与Schedule,组合受限通知;不给普通用户获取原工厂的路径。

Trait Implementations§

§

impl<S: Schedule + Clone, N: TaskNotifier> Clone for TaskFactory<S, N>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S, N> Forget for TaskFactory<S, N>

§

impl<S, N> Freeze for TaskFactory<S, N>
where S: Freeze, N: Freeze,

§

impl<S, N> Move for TaskFactory<S, N>

§

impl<S, N> RefUnwindSafe for TaskFactory<S, N>

§

impl<S, N> Send for TaskFactory<S, N>

§

impl<S, N> Sync for TaskFactory<S, N>

§

impl<S, N> Unpin for TaskFactory<S, N>
where N: Unpin, S: Unpin,

§

impl<S, N> UnsafeUnpin for TaskFactory<S, N>
where S: UnsafeUnpin, N: UnsafeUnpin,

§

impl<S, N> UnwindSafe for TaskFactory<S, N>
where S: UnwindSafe, N: UnwindSafe,

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> OpaqueAttachment for T
where T: Send + Sync + 'static,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.