Function parking_lot_core::unpark_requeue[][src]

pub unsafe fn unpark_requeue<V, C>(
    key_from: usize,
    key_to: usize,
    validate: V,
    callback: C
) -> UnparkResult where
    V: FnOnce() -> RequeueOp,
    C: FnOnce(RequeueOp, UnparkResult) -> UnparkToken

Removes all threads from the queue associated with key_from, optionally unparks the first one and requeues the rest onto the queue associated with key_to.

The validate function is called while both queues are locked and can abort the operation by returning RequeueOp::Abort. It can also choose to unpark the first thread in the source queue while moving the rest by returning RequeueOp::UnparkFirstRequeueRest. Returning RequeueOp::RequeueAll will move all threads to the destination queue.

The callback function is also called while both queues are locked. It is passed the RequeueOp returned by validate and an UnparkResult indicating whether a thread was unparked and whether there are threads still parked in the new queue. This UnparkResult value is also returned by unpark_requeue.

The callback function should return an UnparkToken value which will be passed to the thread that is unparked. If no thread is unparked then the returned value is ignored.

Safety

You should only call this function with an address that you control, since you could otherwise interfere with the operation of other synchronization primitives.

The validate and callback functions are called while the queue is locked and must not panic or call into any function in parking_lot.