pub unsafe fn unpark_filter(
    key: usize,
    filter: impl FnMut(ParkToken) -> FilterOp,
    callback: impl FnOnce(UnparkResult) -> UnparkToken
) -> UnparkResult
Expand description

Unparks a number of threads from the front of the queue associated with key depending on the results of a filter function which inspects the ParkToken associated with each thread.

The filter function is called for each thread in the queue or until FilterOp::Stop is returned. This function is passed the ParkToken associated with a particular thread, which is unparked if FilterOp::Unpark is returned.

The callback function is also called while both queues are locked. It is passed an UnparkResult indicating the number of threads that were unparked and whether there are still parked threads in the queue. This UnparkResult value is also returned by unpark_filter.

The callback function should return an UnparkToken value which will be passed to all threads that are 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 filter and callback functions are called while the queue is locked and must not panic or call into any function in parking_lot.