pub unsafe fn unpark_requeue(
key_from: usize,
key_to: usize,
validate: impl FnOnce() -> RequeueOp,
callback: impl FnOnce(RequeueOp, UnparkResult) -> UnparkToken,
) -> UnparkResultExpand 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.
If validate returns RequeueOp::Abort, the queues are left unchanged,
callback is not called, and a default UnparkResult is returned.
Otherwise, callback is 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 threads remain parked with
key_from. Threads requeued to key_to are not included. 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 both queues are locked
and must not unwind or call into any function in parking_lot.
The parking-lot functions are not reentrant. Calling this function from an asynchronous signal handler may cause undefined behavior, including internal-state corruption or deadlock.