pub struct WorkerPool<A: Address, J, R, C>{ /* private fields */ }Expand description
A fixed, homogeneous, bounded FIFO worker pool.
Each configured nonce names one stable supervised proxy. Jobs are assigned only after a successful worker-creation result makes that slot idle. The retained state records an assignment before the corresponding delivery is returned, and a completion must carry the exact assignment token.
§Panics
Admission or retry propagates a panic from the application payload’s
Clone implementation before changing pool state. Dispatch panics at the
physical assignment-counter boundary before committing its dispatch plan;
the executor’s poison-before-step contract makes that actor turn terminal
rather than exposing partial successor state. The final counter value is
deliberately reserved so every successful batch has a representable
successor counter. This is a Bombay implementation boundary, not an actor
model law.
A worker with any other message protocol cannot form a pool:
use behavior::{Behavior, MailAddr, Never, NoBirths, PoolAssignment, User, WorkerPool};
struct WrongWorker;
impl Behavior for WrongWorker {
type Addr = MailAddr;
type Msg = u8;
type Event = User<MailAddr, u8>;
type Sends = Vec<behavior::Delivery<MailAddr, Never>>;
type Ph = Never;
type Error = Never;
type Birth = NoBirths;
fn init(&mut self) -> behavior::BehaviorActed<Self> { unimplemented!() }
fn transition(&mut self, _: Self::Event) -> behavior::BehaviorActed<Self> { unimplemented!() }
}
let _: Option<WorkerPool<MailAddr, String, (), WrongWorker>> = None;Implementations§
Source§impl<A, J, R, C> WorkerPool<A, J, R, C>
impl<A, J, R, C> WorkerPool<A, J, R, C>
Sourcepub fn new(
nonces: fn(usize) -> A::Nonce,
count: usize,
build: fn(usize) -> C,
backlog_capacity: usize,
interruption: InterruptionPolicy,
restart_policy: RestartPolicy,
max_restarts: u32,
restart_window: Duration,
) -> Result<Self, PoolConfigError<A::Nonce>>
pub fn new( nonces: fn(usize) -> A::Nonce, count: usize, build: fn(usize) -> C, backlog_capacity: usize, interruption: InterruptionPolicy, restart_policy: RestartPolicy, max_restarts: u32, restart_window: Duration, ) -> Result<Self, PoolConfigError<A::Nonce>>
Construct a pool after proving that every configured child route is unique.
§Errors
Returns PoolConfigError::NoWorkers for an empty topology or
PoolConfigError::DuplicateWorker for the first repeated
creator-local nonce. No behavior or creation request is produced.