[−][src]Struct stakker::Core
Core operations available from both Stakker
and Cx
objects
Both &mut Stakker
and &mut Cx
dereference to &mut Core
, so
typically either of those can be used wherever &mut Core
or
&Core
is required.
Methods
impl Core
[src]
pub fn now(&self) -> Instant
[src]
Our view of the current time. Actors should use this in
preference to Instant::now()
for speed and in order to work
in virtual time.
pub fn defer(&mut self, f: impl FnOnce(&mut Stakker) + 'static)
[src]
Defer an operation to be executed later. It is put on the defer queue, and run as soon all operations preceding it have been executed.
pub fn lazy(&mut self, f: impl FnOnce(&mut Stakker) + 'static)
[src]
Defer an operation to executed soon, but lazily. It goes onto a lower priority queue executed once the normal defer queue has been completely cleared (including any further deferred items added whilst clearing that queue). This can be used for flushing data generated in this batch of processing, for example.
pub fn idle(&mut self, f: impl FnOnce(&mut Stakker) + 'static)
[src]
Defer an operation to be executed when this process next becomes idle, i.e. when all other queues are empty and there is no I/O to process. This can be used to implement backpressure on incoming streams, i.e. only fetch more data once there is nothing else left to do.
pub fn after(
&mut self,
dur: Duration,
f: impl FnOnce(&mut Stakker) + 'static
) -> FixedTimerKey
[src]
&mut self,
dur: Duration,
f: impl FnOnce(&mut Stakker) + 'static
) -> FixedTimerKey
Delay an operation to be executed after a duration has passed. This is the same as adding it as a fixed timer. Returns a key that can be used to delete the timer.
pub fn timer_add(
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> FixedTimerKey
[src]
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> FixedTimerKey
Add a fixed timer that expires at the given time. Returns a key that can be used to delete the timer.
pub fn timer_del(&mut self, key: FixedTimerKey) -> bool
[src]
Delete a fixed timer. Returns true
on success, false
if
timer no longer exists (i.e. it expired or was deleted)
pub fn timer_max(
&mut self,
key_variable: &mut MaxTimerKey,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
)
[src]
&mut self,
key_variable: &mut MaxTimerKey,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
)
Add or update a "Max" timer, which expires at the greatest
(latest) expiry time provided. See MaxTimerKey
for the
characteristics of this timer. If the value in the
MaxTimerKey
variable provided is no longer valid
(e.g. expired), creates a new timer using the given closure
and writes a MaxTimerKey
value back to the variable.
Otherwise updates the given timer with the new time. The
variable should be initialised using MaxTimerKey::default()
.
The timer may be cancelled using Core::timer_max_del
.
pub fn timer_max_add(
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> MaxTimerKey
[src]
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> MaxTimerKey
Add a "Max" timer, which expires at the greatest (latest)
expiry time provided. See MaxTimerKey
for the
characteristics of this timer. Returns a key that can be used
to delete or modify the timer.
pub fn timer_max_mod(&mut self, key: MaxTimerKey, expiry: Instant) -> bool
[src]
Update a "Max" timer with a new expiry time. It will be used as the new expiry time only if it is greater than the current expiry time. This call is designed to be very cheap to call frequently.
Returns true
on success, false
if timer no longer exists
(i.e. it expired or was deleted)
pub fn timer_max_del(&mut self, key: MaxTimerKey) -> bool
[src]
Delete a "Max" timer. Returns true
on success, false
if
timer no longer exists (i.e. it expired or was deleted)
pub fn timer_max_active(&mut self, key: MaxTimerKey) -> bool
[src]
Check whether a "Max" timer is active. Returns true
if it
exists and is active, false
if it expired or was deleted or
never existed
pub fn timer_min(
&mut self,
key_variable: &mut MinTimerKey,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
)
[src]
&mut self,
key_variable: &mut MinTimerKey,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
)
Add or update a "Min" timer, which expires at the smallest
(earliest) expiry time provided. See MinTimerKey
for the
characteristics of this timer. If the value in the
MinTimerKey
variable provided is no longer valid
(e.g. expired), creates a new timer using the given closure
and writes a MinTimerKey
value back to the variable.
Otherwise updates the given timer with the new time. The
variable should be initialised using MinTimerKey::default()
.
The timer may be cancelled using Core::timer_min_del
.
pub fn timer_min_add(
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> MinTimerKey
[src]
&mut self,
expiry: Instant,
f: impl FnOnce(&mut Stakker) + 'static
) -> MinTimerKey
Add a "Min" timer, which expires at the smallest (earliest)
expiry time provided. See MinTimerKey
for the
characteristics of this timer. Returns a key that can be used
to delete or modify the timer.
pub fn timer_min_mod(&mut self, key: MinTimerKey, expiry: Instant) -> bool
[src]
Update a "Min" timer with a new expiry time. It will be used as the new expiry time only if it is earlier than the current expiry time. This call is designed to be very cheap to call frequently, so long as the change is within the wiggle-room allowed. Otherwise it causes the working timer to be deleted and added again, readjusting the wiggle-room accordingly.
Returns true
on success, false
if timer no longer exists
(i.e. it expired or was deleted)
pub fn timer_min_del(&mut self, key: MinTimerKey) -> bool
[src]
Delete a "Min" timer. Returns true
on success, false
if
timer no longer exists (i.e. it expired or was deleted)
pub fn timer_min_active(&mut self, key: MinTimerKey) -> bool
[src]
Check whether a "Min" timer is active. Returns true
if it
exists and is active, false
if it expired or was deleted or
never existed
pub fn anymap_get<T: Clone + 'static>(&mut self) -> T
[src]
Gets a clone of a value from the Stakker anymap
. This is
intended to be used to access certain global instances, for
example the I/O poll implementation that this Stakker is
running inside. Panics if the value is not found.
pub fn anymap_try_get<T: Clone + 'static>(&mut self) -> Option<T>
[src]
Tries to get a clone of a value from the Stakker anymap
.
This is intended to be used to access certain global
instances, for example the I/O poll implementation that this
Stakker is running inside. Returns None
if the value is
missing.
pub fn shutdown(&mut self, died: ActorDied)
[src]
Request that the event loop terminate. For this to work, the
event loop must check Core::not_shutdown
each time through
the loop. See also the fwd_shutdown!
macro which can be
used as the notify handler for an actor, to shut down the
event loop when that actor terminates. The event loop code
can obtain the ActorDied
instance using shutdown_reason
.
pub fn not_shutdown(&self) -> bool
[src]
Should the event loop continue running? Returns true
if
there is no active shutdown in progress.
pub fn shutdown_reason(&mut self) -> Option<ActorDied>
[src]
Get the reason for shutdown, if shutdown was requested. After
calling this, the shutdown flag is cleared,
i.e. not_shutdown
will return false
and the event loop
could continue to run.
pub fn deferrer(&self) -> Deferrer
[src]
Get a Deferrer
instance which can be used to defer calls
from contexts in the same thread which don't have access to
Core
, for example drop handlers. Calls submitted via a
Deferrer
go onto the lazy queue.
pub fn waker(&mut self, cb: impl FnMut(&mut Stakker, bool) + 'static) -> Waker
[src]
Register a wake handler callback, and obtain a Waker
instance which can be passed to another thread. The wake
handler will always be executed in the main thread. When
Waker::wake
is called in another thread, a wake-up
is scheduled to occur in the main thread, using the wake-up
mechanism provided by the I/O poller. Then when that wake-up
is received, the corresponding wake handler is executed. Note
that this is efficient -- if many wake handlers are scheduled
around the same time, they share the same main thread wake-up.
The wake handler is called in the main thread with arguments
of (stakker, deleted)
. Note that there is a small chance of
a spurious wake call happening occasionally, so the wake
handler code must be ready for that. If deleted
is true
then the Waker
was dropped, and this wake handler is
also just about to be dropped.
This call panics if no I/O poller has yet set up a waker using
Stakker::set_poll_waker
.
Auto Trait Implementations
impl !RefUnwindSafe for Core
impl !Send for Core
impl !Sync for Core
impl Unpin for Core
impl !UnwindSafe for Core
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,