Skip to main content

ActorScheduler

Struct ActorScheduler 

Source
pub struct ActorScheduler { /* private fields */ }
Expand description

Work-stealing actor scheduler.

Implementations§

Source§

impl ActorScheduler

Source

pub fn new(config: SchedulerConfig) -> Self

Create a new actor scheduler.

Source

pub fn with_executor( config: SchedulerConfig, executor: Arc<dyn ActorExecutor>, ) -> Self

Create a new scheduler with an executor.

Source

pub fn with_resource_policy( config: SchedulerConfig, executor: Arc<dyn ActorExecutor>, resource_policy: Arc<dyn ResourcePolicy>, ) -> Self

Create a new scheduler with an executor and a resource policy.

The policy gates actor spawns and message sends; see crate::policy::ResourcePolicy for the (cheap, non-blocking) contract.

Source

pub fn set_executor(&mut self, executor: Arc<dyn ActorExecutor>)

Set the executor for WASM execution.

Source

pub fn set_degradation_with_monitor( &mut self, monitor: Arc<dyn ResourceMonitor>, elevated_batch_factor: f64, )

Set the degradation controller for OS-level admission control.

When set, spawn_named will check resource pressure before creating a new actor. Critical pressure returns an error; Elevated logs a debug message but allows the spawn.

Source

pub fn start(&self) -> Result<(), Error>

Start the scheduler.

Source

pub fn stop(&self)

Stop the scheduler.

Source

pub fn spawn(&self) -> Result<ActorId>

Spawn a new actor.

Source

pub fn spawn_named(&self, name: Option<String>) -> Result<ActorId>

Spawn a new actor with a name.

Source

pub fn kill(&self, id: &ActorId) -> Result<()>

Kill an actor.

Source

pub fn set_actor_running(&self, id: &ActorId) -> Result<()>

Set an actor to running state.

Source

pub fn set_actor_state(&self, id: &ActorId, state: ActorState) -> Result<()>

Set an actor state.

Source

pub async fn send(&self, target: ActorId, message: Message) -> Result<()>

Send a message to an actor.

Source

pub async fn send_batch( &self, target: ActorId, messages: Vec<Message>, ) -> Result<()>

Send a batch of messages to an actor in a single queue operation.

This is more efficient than calling send in a loop because it performs one quota/rate-limit check and pushes a single Task to the work-stealing queue for the entire batch.

Source

pub fn try_send(&self, target: ActorId, message: Message) -> Result<()>

Try to send a message (non-blocking).

Source

pub fn registry(&self) -> &Arc<ActorRegistry> ⓘ

Get the actor registry.

Source

pub fn stats(&self) -> SchedulerStats

Get scheduler statistics.

Trait Implementations§

Source§

impl Drop for ActorScheduler

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more