Struct simple_async_local_executor::Executor [−][src]
pub struct Executor { /* fields omitted */ }
Single-threaded polling-based executor
This is a thin-wrapper (using Rc
) around the real executor, so that this struct can be
cloned and passed around.
See the module documentation for more details.
Implementations
impl Executor
[src]
impl Executor
[src]pub fn spawn(&self, future: impl Future<Output = ()> + 'static)
[src]
Spawn a new task to be run by this executor.
Example
async fn nop() {} let executor = Executor::default(); executor.spawn(nop()); assert_eq!(executor.step(), false);
pub fn create_event_handle(&self) -> EventHandle
[src]
pub fn notify_event(&self, handle: &EventHandle)
[src]
Notify an event.
All tasks currently waiting on this event will
progress at the next call to step
.
pub fn event(&self, handle: &EventHandle) -> EventFutureⓘNotable traits for EventFuture
impl Future for EventFuture type Output = ();
[src]
Notable traits for EventFuture
impl Future for EventFuture type Output = ();
Create an event future.
Once this future is awaited, its task will be blocked until the next step
after notify_event
is called with this handle
.
pub fn step(&self) -> bool
[src]
Run each non-blocked task exactly once.
Return whether there are any non-completed tasks.
Example
let executor = Executor::default(); let event = executor.create_event_handle(); async fn wait_event(event: EventHandle, executor: Executor) { executor.event(&event).await; } executor.spawn(wait_event(event.clone(), executor.clone())); assert_eq!(executor.step(), true); // still one task in the queue executor.notify_event(&event); assert_eq!(executor.step(), false); // no more task in the queue
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Executor
impl !RefUnwindSafe for Executor
impl !UnwindSafe for Executor
impl !UnwindSafe for Executor