pub unsafe fn unpark_requeue(
    key_from: usize,
    key_to: usize,
    validate: impl FnOnce() -> RequeueOp,
    callback: impl FnOnce(RequeueOp, UnparkResult) -> UnparkToken
) -> UnparkResult
Expand description

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. Its return value will determine which operation is performed, or whether the operation should be aborted. See RequeueOp for details about the different possible return values.

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.