pub struct QueuedRuntime { /* private fields */ }
Expand description

A very small async runtime, with support for adding more tasks as it runs. This uses a VecDeque internally.

Implementations§

Creates a new, empty QueuedRuntime. Awaiting this does nothing unless futures are pushed to it.

Examples found in repository?
examples/tcp.rs (line 14)
13
14
15
16
17
fn main() {
    let mut runtime = QueuedRuntime::new();
    runtime.push(go(("0.0.0.0", 5000)));
    sync(runtime);
}
More examples
Hide additional examples
examples/recursion.rs (line 7)
6
7
8
9
10
fn main() {
    let mut runtime = QueuedRuntime::new();
    runtime.push(print_something_after_ms(0));
    sync(runtime);
}
examples/runtime.rs (line 5)
4
5
6
7
8
9
10
fn main() {
    let mut runtime = QueuedRuntime::new();
    for _ in 0..50 {
        runtime.push(print_something_after_ms(2000));
    }
    sync(runtime);
}

Creates a new QueuedRuntime. Unlike new(), this adds a single future immediately, so awaiting this will have an effect.

Creates a new QueuedRuntime. Unlike new(), this adds a single future immediately, so awaiting this will have an effect.

Trait Implementations§

Returns the “default value” for a type. Read more
The type of value produced on completion.
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Adds a new future to the queue to be completed.
Returns if a future by some ID is still running.
Asynchronously sleeps
Stops the runtime

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The output that the future will produce on completion.
Which kind of future are we turning this into?
Creates a future from a value. Read more
Adds a new future to the queue to be completed.
Adds a new future to the queue to be completed and returns a future waiting for the added future’s completion.
Asynchronously sleeps
Stops the runtime. This does not exit the process.
Adds a new future to the queue to be completed.
Adds a new future to the queue to be completed and returns a future waiting for the added future’s completion.
Asynchronously sleeps some amount of milliseconds
Internal function to make a new runtime. Only to be used by new() to create an OwnedRuntime. Automatically implemented for T where T: Default
Constructs some new runtime
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.