[−][src]Trait fumio_utils::park::Park
A trait to allow combining (nesting) of runtime components (IO reactor, timers, pool of futures)
The most inner component is the one that blocks the thread until there is more work, this is
usually the IO reactor or something based on std::thread::park{_timeout}
.
Required methods
fn waker(&self) -> Waker
Return a Waker
that is used to interrupt park
Specific semantic:
- When leaving
park
the "wakeup" notification is reset - When called before
park
is called (or beforepark
suspends),park
mustn't suspend the thread at all - When called while
park
suspends the thread it must interrupt it, andpark
must return "soon"
fn park(&mut self, enter: &mut Enter, duration: Option<Duration>)
Park thread
When duration
is None
blocks "forever" (until interrupted by a Waker
).
Even when duration
is Some(0 seconds)
you want to call park
: it might need to do
routine work (like fetching pending IO events) even when not actually suspending the
thread.