Skip to main content

RuntimeWait

Trait RuntimeWait 

pub trait RuntimeWait: RuntimeTime {
    // Provided methods
    fn wait_one_timeout<T>(
        &self,
        duration: Duration,
    ) -> (WaitOneTimeout<Self::Timer, T>, OneSender<T>) { ... }
    fn wait_any_timeout<T>(
        &self,
        duration: Duration,
    ) -> (WaitAnyTimeout<Self::Timer, T>, AnySender<T>) { ... }
    fn wait_all_timeout<T>(
        &self,
        duration: Duration,
    ) -> (WaitAllTimeout<Self::Timer, T>, AllSender<T>) { ... }
}
Expand description

只依赖原等待与RuntimeTime;不增加T的Send/Sync/’static/Unpin约束。

Provided Methods§

fn wait_one_timeout<T>( &self, duration: Duration, ) -> (WaitOneTimeout<Self::Timer, T>, OneSender<T>)

返回一次交值等待与原单发送者;通过timeout_on组合,不新增T的Send/Sync/’static/Unpin约束。

Examples found in repository?
examples/api_bounds.rs (line 23)
22fn borrowed_wait<R: Runtime>(runtime: &R, value: &str) {
23    let (_wait, sender) = runtime.wait_one_timeout::<&str>(Duration::from_millis(2));
24    let _sent = sender.send(value);
25    let (_wait, sender) = runtime.wait_any_timeout::<Cell<u32>>(Duration::from_millis(3));
26    let _sent = sender.send(Cell::new(1));
27}

fn wait_any_timeout<T>( &self, duration: Duration, ) -> (WaitAnyTimeout<Self::Timer, T>, AnySender<T>)

返回并发竞争一次交值的等待与可克隆发送者;保留原胜者及关闭错误语义。

Examples found in repository?
examples/api_bounds.rs (line 25)
22fn borrowed_wait<R: Runtime>(runtime: &R, value: &str) {
23    let (_wait, sender) = runtime.wait_one_timeout::<&str>(Duration::from_millis(2));
24    let _sent = sender.send(value);
25    let (_wait, sender) = runtime.wait_any_timeout::<Cell<u32>>(Duration::from_millis(3));
26    let _sent = sender.send(Cell::new(1));
27}

fn wait_all_timeout<T>( &self, duration: Duration, ) -> (WaitAllTimeout<Self::Timer, T>, AllSender<T>)

返回全部交值等待与原登记发送者;正常返回完整有序向量,超时不交部分结果。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§