# [−][src]Function parking_lot_core::park

    pub unsafe fn park<V, B, T>(
        key: usize,
        validate: V,
        before_sleep: B,
        timed_out: T,
        park_token: ParkToken,
        timeout: Option<Instant>
    ) -> ParkResult where
        V: FnOnce() -> bool,
        B: FnOnce(),
        T: FnOnce(usize, 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.

The `timed_out` function is also called while the queue is locked, but only if the timeout was reached. It is passed the key of the queue it was in when it timed out, which may be different from the original key if `unpark_requeue` was called. It is also passed a bool which indicates whether it was the last thread in the queue.

# 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 `timed_out` functions are 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`, `unpark_all`, `unpark_requeue` or `unpark_filter`, but it is not allowed to call `park` or panic.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)