pub fn requeue(
        &self,
        current_value: i32,
        wake_count: usize,
        requeue_count: usize,
        requeue_futex: &Arc<Futex>,
        new_requeue_owner: Option<Arc<Thread>>,
    ) -> ZxResult {
        let mut inner = self.inner.lock();
        // check value
        if self.value.load(Ordering::SeqCst) != current_value {
            return Err(ZxError::BAD_STATE);
        }
        // wake
        for _ in 0..wake_count {
            if let Some(waiter) = inner.waiter_queue.pop_front() {
                waiter.wake();
            } else {
                break;
            }
        }
        // requeue
        let mut new_inner = requeue_futex.inner.lock();
        let requeue_count = requeue_count.min(inner.waiter_queue.len());
        for waiter in inner.waiter_queue.drain(..requeue_count) {
            waiter.reset_futex(requeue_futex.clone());
            new_inner.waiter_queue.push_back(waiter);
        }
        // set owner
        inner.set_owner(None);
        new_inner.set_owner(new_requeue_owner);
        Ok(())
    }
/// Requeuing is a generalization of waking.
///
/// First, verifies that the value in `current_value` matches the value of the futex,
/// and if not reports `ZxError::BAD_STATE`. After waking `wake_count` threads,
/// `requeue_count` threads are moved from the original futex's wait queue to the
/// wait queue corresponding to another `requeue_futex`.
///
/// This requeueing behavior may be used to avoid thundering herds on wake.
///
/// # Ownership
///
/// The owner of this futex is set to nothing, regardless of the wake count.
/// The owner of the `requeue_futex` is set to the thread `new_requeue_owner`.
Requeuing is a generalization of waking.
First, verifies that the value in `current_value` matches the value of the futex,
and if not reports `ZxError::BAD_STATE`.

This requeueing behavior may be used to avoid thundering herds on wake.
Requeuing is a generalization of waking . First verifies that the value in ` current_value ` matches the value of the futex and if not reports ` ZxError :: BAD_STATE ` . This requeueing behavior may be used to avoid thundering herds on wake .
pub fn requeue(
        &self,
        current_value: i32,
        wake_count: usize,
        requeue_count: usize,
        requeue_futex: &Arc<Futex>,
        new_requeue_owner: Option<Arc<Thread>>,
    ) -> ZxResult {
        let mut inner = self.inner.lock();
        // check value
        if self.value.load(Ordering::SeqCst) != current_value {
            return Err(ZxError::BAD_STATE);
        }
        // wake
        for _ in 0..wake_count {
            if let Some(waiter) = inner.waiter_queue.pop_front() {
                waiter.wake();
            } else {
                break;
            }
        }
        // requeue
        let mut new_inner = requeue_futex.inner.lock();
        let requeue_count = requeue_count.min(inner.waiter_queue.len());
        for waiter in inner.waiter_queue.drain(..requeue_count) {
            waiter.reset_futex(requeue_futex.clone());
            new_inner.waiter_queue.push_back(waiter);
        }
        // set owner
        inner.set_owner(None);
        new_inner.set_owner(new_requeue_owner);
        Ok(())
    }
pub fn requeue ( & self , current_value : i32 , wake_count : usize , requeue_count : usize , requeue_futex : & Arc < Futex > , new_requeue_owner : Option < Arc < Thread > > , ) -> ZxResult { let mut inner = self . inner . lock ( ) ; // check value if self . value . load ( Ordering :: SeqCst ) != current_value { return Err ( ZxError :: BAD_STATE ) ; } // wake for _ in 0 .. wake_count { if let Some ( waiter ) = inner . waiter_queue . pop_front ( ) { waiter . wake ( ) ; } else { break ; } } // requeue let mut new_inner = requeue_futex . inner . lock ( ) ; let requeue_count = requeue_count . min ( inner . waiter_queue . len ( ) ) ; for waiter in inner . waiter_queue . drain ( .. requeue_count ) { waiter . reset_futex ( requeue_futex . clone ( ) ) ; new_inner . waiter_queue . push_back ( waiter ) ; } // set owner inner . set_owner ( None ) ; new_inner . set_owner ( new_requeue_owner ) ; Ok ( ( ) ) }
Requeuing is a generalization of waking.
Requeuing is a generalization of waking .
&self
current_value
i32
wake_count
usize
requeue_count
usize
requeue_futex
&Arc<Futex>
new_requeue_owner
Option<Arc<Thread>>
&self
current_value
i32
wake_count
usize
requeue_count
usize
requeue_futex
&Arc<Futex>
new_requeue_owner
Option<Arc<Thread>>
ownership
The owner of this futex is set to nothing, regardless of the wake count.
The owner of the `requeue_futex` is set to the thread `new_requeue_owner`.
The owner of this futex is set to nothing regardless of the wake count . The owner of the ` requeue_futex ` is set to the thread ` new_requeue_owner ` .