pi-async-runtime-core 0.1.4

与具体执行器和队列实现无关的运行时核心能力
Documentation


/// 预先保管一份唯一服务身份,只有消费本对象才能用于构造。
#[doc(hidden)]
pub struct RuntimeIdReservation {
    id: RuntimeId,
}
impl RuntimeIdReservation {

    /// 预留唯一身份(identity),同时保留一次消费资格。
    pub fn reserve() -> pi_result::Result<Self> {
        reserve_runtime_id_inner()
    }

    /// 读取预备服务的编号(RuntimeId)。
    pub fn id(&self) -> RuntimeId {
        reserved_runtime_id_inner(self)
    }

}

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

    /// 消耗与拟启动成员配对的预备身份,不使用外部可复制编号。
    #[doc(hidden)]
    pub fn from_reservation(
        reservation: RuntimeIdReservation, schedule: S, notifier: N, queue_support: QueueSupport,
    ) -> Self {
        factory_from_reservation_inner(reservation, schedule, notifier, queue_support)
    }

}

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

    /// 将已核对归属的可执行句柄交还实际原调度器(scheduler)。
    #[doc(hidden)]
    pub fn return_to_schedule(&self, task: Runnable) {
        factory_return_inner(self, task)
    }

}

include!("member_task_factory_inner.rs");