pub struct Executor { /* private fields */ }Expand description
A dual-queue executor optimized for singlethreaded usecase, with support for multithreaded wakes.
Same-thread wakes (Waker::wake) will schedule tasks within the queue
directly; cross-thread wakes will send task id’s to a channel, and
piggybacked to singlethreaded wakes or ticks. This ensures maximum
performance for singlethreaded scenario at the trade-off of worse tail
latency for multithreaded wake-ups.
Optionally, all Wakers generated from this executor can contain an extra
data, parameterized as E.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn with_config(config: ExecutorConfig) -> Self
pub fn with_config(config: ExecutorConfig) -> Self
Create a new executor with config.
Sourcepub fn spawn<F: Future + 'static>(&self, fut: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn<F: Future + 'static>(&self, fut: F) -> JoinHandle<F::Output> ⓘ
Spawn a future onto the executor.
Sourcepub fn tick(&self) -> bool
pub fn tick(&self) -> bool
Retrieve all sync tasks, schedule those to the tail of hot queue
and run at most max_interval tasks.
Running start with hot tasks, then cold ones. Finished tasks will
be pushed back to tail of cold queue.
Return whether there are still hot tasks after the tick.