pub struct TaskPool {
pub id: String,
pub pool_size: usize,
pub strategy: LoadBalancingStrategy,
/* private fields */
}Expand description
A pool of worker tasks for load balancing
Fields§
§id: StringPool identifier
pool_size: usizeNumber of workers in the pool
strategy: LoadBalancingStrategyLoad balancing strategy
Implementations§
Source§impl TaskPool
impl TaskPool
Sourcepub fn new(
id: impl Into<String>,
pool_size: usize,
strategy: LoadBalancingStrategy,
) -> Self
pub fn new( id: impl Into<String>, pool_size: usize, strategy: LoadBalancingStrategy, ) -> Self
Create a new task pool
Sourcepub async fn get_next_worker(&self) -> usize
pub async fn get_next_worker(&self) -> usize
Get the next worker index based on the load balancing strategy
Sourcepub fn build_pool<T, F>(&self, task_factory: F) -> Supervisor
pub fn build_pool<T, F>(&self, task_factory: F) -> Supervisor
Build a supervisor with pooled workers
Auto Trait Implementations§
impl !RefUnwindSafe for TaskPool
impl !UnwindSafe for TaskPool
impl Freeze for TaskPool
impl Send for TaskPool
impl Sync for TaskPool
impl Unpin for TaskPool
impl UnsafeUnpin for TaskPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more