pub struct ActorRuntime { /* private fields */ }Expand description
Runtime state of an actor
Corresponds to Lean: structure ActorRuntime
Implementations§
Source§impl ActorRuntime
impl ActorRuntime
Sourcepub fn empty(capacity: usize) -> Self
pub fn empty(capacity: usize) -> Self
Create empty actor runtime
Corresponds to Lean: def ActorRuntime.empty (capacity : Nat) : ActorRuntime
Sourcepub fn can_receive(&self) -> bool
pub fn can_receive(&self) -> bool
Check if actor can receive (mailbox not empty)
Corresponds to Lean: def ActorRuntime.can_receive (ar : ActorRuntime) : Bool
Sourcepub fn can_send(&self, target_capacity: usize) -> bool
pub fn can_send(&self, target_capacity: usize) -> bool
Check if actor can send (pending queue not full)
Corresponds to Lean: def ActorRuntime.can_send (ar : ActorRuntime) (targetCapacity : Nat) : Bool
Sourcepub fn mailbox_has_space(&self) -> bool
pub fn mailbox_has_space(&self) -> bool
Check if mailbox has space
Corresponds to Lean: def ActorRuntime.mailbox_has_space (ar : ActorRuntime) : Bool
Sourcepub fn enqueue_pending(&self, msg: Message) -> Self
pub fn enqueue_pending(&self, msg: Message) -> Self
Enqueue message to pending
Corresponds to Lean: def ActorRuntime.enqueue_pending
Sourcepub fn enqueue_pending_mut(&mut self, msg: Message)
pub fn enqueue_pending_mut(&mut self, msg: Message)
Enqueue message to pending (mutating version)
Sourcepub fn deliver(&self) -> Self
pub fn deliver(&self) -> Self
Deliver message from pending to mailbox
Corresponds to Lean: def ActorRuntime.deliver
Returns the new state. If pending is empty or mailbox is full, returns unchanged state.
Sourcepub fn deliver_mut(&mut self) -> Result<bool, ActorError>
pub fn deliver_mut(&mut self) -> Result<bool, ActorError>
Deliver message from pending to mailbox (mutating version)
Returns Ok(true) if delivered, Ok(false) if mailbox full, Err if no pending.
§Errors
Returns ActorError::NoMessage if the pending queue is empty.
Sourcepub fn consume(&self) -> (Self, Option<Message>)
pub fn consume(&self) -> (Self, Option<Message>)
Consume message from mailbox
Corresponds to Lean: def ActorRuntime.consume
Returns (new_state, Option<Message>).
Sourcepub fn consume_mut(&mut self) -> Option<Message>
pub fn consume_mut(&mut self) -> Option<Message>
Consume message from mailbox (mutating version)
Sourcepub fn set_blocked(&self, on: ActorId) -> Self
pub fn set_blocked(&self, on: ActorId) -> Self
Set blocked state (for deadlock analysis)
Corresponds to Lean: def ActorRuntime.set_blocked
Sourcepub fn set_blocked_mut(&mut self, on: ActorId)
pub fn set_blocked_mut(&mut self, on: ActorId)
Set blocked state (mutating version)
Sourcepub fn unblock(&self) -> Self
pub fn unblock(&self) -> Self
Clear blocked state
Corresponds to Lean: def ActorRuntime.unblock
Sourcepub fn unblock_mut(&mut self)
pub fn unblock_mut(&mut self)
Clear blocked state (mutating version)
Sourcepub fn blocked_on(&self) -> Option<ActorId>
pub fn blocked_on(&self) -> Option<ActorId>
Get the blocked-on actor (if any)
Sourcepub fn is_blocked(&self) -> bool
pub fn is_blocked(&self) -> bool
Check if actor is blocked
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Get the pending queue length
Sourcepub fn mailbox_len(&self) -> usize
pub fn mailbox_len(&self) -> usize
Get the mailbox length
Sourcepub fn pending_send(&self) -> Option<&Message>
pub fn pending_send(&self) -> Option<&Message>
Get the pending send message
Sourcepub fn set_pending_send(&mut self, msg: Option<Message>)
pub fn set_pending_send(&mut self, msg: Option<Message>)
Set the pending send message
Trait Implementations§
Source§impl Clone for ActorRuntime
impl Clone for ActorRuntime
Source§fn clone(&self) -> ActorRuntime
fn clone(&self) -> ActorRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more