# Struct bitflags::__core::sync::StaticRwLock [−] [src]

    pub struct StaticRwLock {
        // some fields omitted
    }

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Structure representing a statically allocated RwLock.

This structure is intended to be used inside of a `static` and will provide automatic global access as well as lazy initialization. The internal resources of this RwLock, however, must be manually deallocated.

# Examples

    #![feature(static_rwlock)]

    use std::sync::{StaticRwLock, RW_LOCK_INIT};

    static LOCK: StaticRwLock = RW_LOCK_INIT;

    {
        let _g = LOCK.read().unwrap();
        // ... shared read access
    }
    {
        let _g = LOCK.write().unwrap();
        // ... exclusive write access
    }
    unsafe { LOCK.destroy() } // free all resources

## Methods

### `impl StaticRwLock`

#### `const fn new() -> StaticRwLock`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Creates a new rwlock.

#### `fn read(&'static self) -> Result<RwLockReadGuard<'static, ()>, PoisonError<RwLockReadGuard<'static, ()>>>`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Locks this rwlock with shared read access, blocking the current thread until it can be acquired.

See `RwLock::read`.

#### `fn try_read(&'static self) -> Result<RwLockReadGuard<'static, ()>, TryLockError<RwLockReadGuard<'static, ()>>>`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Attempts to acquire this lock with shared read access.

See `RwLock::try_read`.

#### `fn write(&'static self) -> Result<RwLockWriteGuard<'static, ()>, PoisonError<RwLockWriteGuard<'static, ()>>>`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Locks this rwlock with exclusive write access, blocking the current thread until it can be acquired.

See `RwLock::write`.

#### `fn try_write(&'static self) -> Result<RwLockWriteGuard<'static, ()>, TryLockError<RwLockWriteGuard<'static, ()>>>`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Attempts to lock this rwlock with exclusive write access.

See `RwLock::try_write`.

#### `unsafe fn destroy(&'static self)`

Unstable (`static_rwlock`)

: may be merged with RwLock in the future

Deallocates all resources associated with this static lock.

This method is unsafe to call as there is no guarantee that there are no active users of the lock, and this also doesn't prevent any future users of this lock. This method is required to be called to not leak memory on all platforms.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## 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`)