Function parking_lot::park
[−]
[src]
pub unsafe fn park(key: usize, validate: &mut FnMut() -> bool, before_sleep: &mut FnMut(), timeout: Option<Instant>) -> bool
Parks the current thread in the queue associated with the given key.
The validate function is called while the queue is locked and can abort
the operation by returning false. If validate returns true then the
current thread is appended to the queue and the queue is unlocked.
The before_sleep function is called after the queue is unlocked but before
the thread is put to sleep. The thread will then sleep until it is unparked
or the given timeout is reached.
This function returns true if the thread was unparked by a call to
unpark_one or unpark_all, and false if the validation function failed
or the timeout was reached.
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 function is called while the queue is locked and must not
panic or call into any function in parking_lot.
The before_sleep function is called outside the queue lock and is allowed
to call unpark_one or unpark_all, but it is not allowed to call park
or panic.