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§

Source

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/runtime_bounds.rs (line 63)
39fn roots(runtime: &ConcurrentRuntime, handle: &Handle) {
40    let value = Rc::new(7);
41    let _: Rc<usize> = runtime.block_on(Borrowed {
42        value: &value,
43        fixed: PhantomPinned,
44    });
45    let _: Rc<usize> = handle.block_on(Borrowed {
46        value: &value,
47        fixed: PhantomPinned,
48    });
49    let _ = runtime.timeout_on(
50        Borrowed {
51            value: &value,
52            fixed: PhantomPinned,
53        },
54        std::time::Duration::from_millis(1),
55    );
56    let _ = handle.spawn(SendNotSync {
57        value: Cell::new(3),
58        fixed: PhantomPinned,
59    });
60    let _ = ConcurrentRuntime::spawn_local(async { Rc::new(1usize) });
61    let _ = ConcurrentRuntime::spawn_local_front(async { Rc::new(2usize) });
62    let _ = SerialRuntime::idle_local(async { Cell::new(4usize) });
63    let _ = handle.wait_one_timeout::<Rc<usize>>(std::time::Duration::from_secs(2));
64}
Source

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

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

Source

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§

§

impl<C, E, I, T> RuntimeWait for RuntimeHandle<C, E, I, T>

§

impl<M, C, P, H, E, I, T> RuntimeWait for ConfiguredRuntime<M, C, P, H, E, I, T>