pub struct Dispatcher { /* private fields */ }Expand description
Where coroutines run and which Clock they measure time with.
Cheap to clone. Coroutines launched with a Dispatcher must be Send
because it may move them between threads; use a ConfinedDispatcher and
a MainScope for work that holds Rc or other
thread-bound values.
Implementations§
Source§impl Dispatcher
impl Dispatcher
Sourcepub fn new(executor: impl Dispatch, clock: Arc<dyn Clock>) -> Self
pub fn new(executor: impl Dispatch, clock: Arc<dyn Clock>) -> Self
A dispatcher that schedules through executor and measures time on clock.
Sourcepub fn clock(&self) -> &Arc<dyn Clock> ⓘ
pub fn clock(&self) -> &Arc<dyn Clock> ⓘ
The clock coroutines on this dispatcher measure time with.
Sourcepub fn limited_parallelism(&self, parallelism: usize) -> Self
pub fn limited_parallelism(&self, parallelism: usize) -> Self
A view of this dispatcher that runs at most parallelism coroutine
steps at once, in the order they were dispatched — Kotlin’s
limitedParallelism. Views share the underlying threads. A
parallelism of zero counts as one.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Dispatcher
impl !UnwindSafe for Dispatcher
impl Forget for Dispatcher
impl Freeze for Dispatcher
impl Move for Dispatcher
impl Send for Dispatcher
impl Sync for Dispatcher
impl Unpin for Dispatcher
impl UnsafeUnpin for Dispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more