pub(crate) fn new(weights: Vec<(K, NonZeroUsize)>) -> Self {
        assert!(!weights.is_empty(), "must provide at least one slot");

        let queues = weights
            .iter()
            .map(|(idx, _)| (*idx, QueueState::new()))
            .collect();
        let slots: Vec<Slot<K>> = weights
            .into_iter()
            .map(|(key, tickets)| Slot {
                key,
                tickets: tickets.get(),
            })
            .collect();
        let active_slot = slots[0];

        WeightedRoundRobin {
            state: Mutex::new(IterationState {
                active_slot,
                active_slot_idx: 0,
            }),
            slots,
            queues,
            total: Semaphore::new(0),
            sealed: AtomicBool::new(false),
        }
    }
/// Creates a new weighted round-robin scheduler.
///
/// Creates a queue for each pair given in `weights`. The second component of each `weight` is
/// the number of times to return items from one queue before moving on to the next one.
Creates a new weighted round-robin scheduler.
Creates a queue for each pair given in `weights`. The second component of each `weight` is
the number of times to return items from one queue before moving on to the next one.
Creates a new weighted round - robin scheduler . Creates a queue for each pair given in ` weights ` . The second component of each ` weight ` is the number of times to return items from one queue before moving on to the next one .
pub(crate) fn new(weights: Vec<(K, NonZeroUsize)>) -> Self {
        assert!(!weights.is_empty(), "must provide at least one slot");
        let queues = weights
            .iter()
            .map(|(idx, _)| (*idx, QueueState::new()))
            .collect();
        let slots: Vec<Slot<K>> = weights
            .into_iter()
            .map(|(key, tickets)| Slot {
                key,
                tickets: tickets.get(),
            })
            .collect();
        let active_slot = slots[0];
        WeightedRoundRobin {
            state: Mutex::new(IterationState {
                active_slot,
                active_slot_idx: 0,
            }),
            slots,
            queues,
            total: Semaphore::new(0),
            sealed: AtomicBool::new(false),
        }
    }
pub ( crate ) fn new ( weights : Vec < ( K , NonZeroUsize ) > ) -> Self { assert ! ( weights is_empty ( ) " " ) ; let queues = weights . iter ( ) . map ( | ( idx , _ ) | ( * idx , QueueState :: new ( ) ) ) . collect ( ) ; let slots : Vec < Slot < K > > = weights . into_iter ( ) . map ( | ( key , tickets ) | Slot { key , tickets : tickets . get ( ) , } ) . collect ( ) ; let active_slot = slots [ 0 ] ; WeightedRoundRobin { state : Mutex :: new ( IterationState { active_slot , active_slot_idx : 0 , } ) , slots , queues , total : Semaphore :: new ( 0 ) , sealed : AtomicBool :: new ( false ) , } }
Creates a new weighted round-robin scheduler.
Creates a new weighted round - robin scheduler .
weights
Vec<(K, NonZeroUsize)>
weights
Vec<(K, NonZeroUsize)>