pub struct ActorScheduler { /* private fields */ }Expand description
Work-stealing actor scheduler.
Implementations§
Source§impl ActorScheduler
impl ActorScheduler
Sourcepub fn new(config: SchedulerConfig) -> Self
pub fn new(config: SchedulerConfig) -> Self
Create a new actor scheduler.
Sourcepub fn with_executor(
config: SchedulerConfig,
executor: Arc<dyn ActorExecutor>,
) -> Self
pub fn with_executor( config: SchedulerConfig, executor: Arc<dyn ActorExecutor>, ) -> Self
Create a new scheduler with an executor.
Sourcepub fn with_resource_policy(
config: SchedulerConfig,
executor: Arc<dyn ActorExecutor>,
resource_policy: Arc<dyn ResourcePolicy>,
) -> Self
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.
Sourcepub fn set_executor(&mut self, executor: Arc<dyn ActorExecutor>)
pub fn set_executor(&mut self, executor: Arc<dyn ActorExecutor>)
Set the executor for WASM execution.
Sourcepub fn set_degradation_with_monitor(
&mut self,
monitor: Arc<dyn ResourceMonitor>,
elevated_batch_factor: f64,
)
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.
Sourcepub fn spawn_named(&self, name: Option<String>) -> Result<ActorId>
pub fn spawn_named(&self, name: Option<String>) -> Result<ActorId>
Spawn a new actor with a name.
Sourcepub fn set_actor_running(&self, id: &ActorId) -> Result<()>
pub fn set_actor_running(&self, id: &ActorId) -> Result<()>
Set an actor to running state.
Sourcepub fn set_actor_state(&self, id: &ActorId, state: ActorState) -> Result<()>
pub fn set_actor_state(&self, id: &ActorId, state: ActorState) -> Result<()>
Set an actor state.
Sourcepub async fn send(&self, target: ActorId, message: Message) -> Result<()>
pub async fn send(&self, target: ActorId, message: Message) -> Result<()>
Send a message to an actor.
Sourcepub async fn send_batch(
&self,
target: ActorId,
messages: Vec<Message>,
) -> Result<()>
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.
Sourcepub fn try_send(&self, target: ActorId, message: Message) -> Result<()>
pub fn try_send(&self, target: ActorId, message: Message) -> Result<()>
Try to send a message (non-blocking).
Sourcepub fn registry(&self) -> &Arc<ActorRegistry> ⓘ
pub fn registry(&self) -> &Arc<ActorRegistry> ⓘ
Get the actor registry.
Sourcepub fn stats(&self) -> SchedulerStats
pub fn stats(&self) -> SchedulerStats
Get scheduler statistics.