Skip to main content

Policy

Trait Policy 

Source
pub trait Policy: Sized {
    type Overflow: Overflow<Self>;

    // Required method
    fn handle(overflow: &mut Self::Overflow, message: Self);
}
Expand description

Overflow behavior for actor messages when an inbox is full.

Required Associated Types§

Source

type Overflow: Overflow<Self>

Overflow storage used by this policy.

Required Methods§

Source

fn handle(overflow: &mut Self::Overflow, message: Self)

Reliably handle message when it cannot enter the bounded ready queue immediately.

This may retain the message, coalesce it with retained work, replace older retained work, or deliberately do no work because the message is already satisfied, superseded, or no longer needed (for example, a request whose response channel is already closed).

§Warning

Do not enqueue into the same mailbox from this method or from destructors triggered by editing overflow. This method runs while the mailbox holds its overflow lock, so same mailbox re-entry can deadlock.

This method should not unwind after mutating overflow. A panic, including one from a destructor triggered while editing overflow, can leave retained overflow data stranded in the mailbox.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§