Struct std::sync::StaticRwLock
[−]
[src]
pub struct StaticRwLock { // some fields omitted }
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
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)] fn main() { 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 }#![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
[src]
fn new() -> StaticRwLock
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
Creates a new rwlock.
fn read(&'static self) -> LockResult<RwLockReadGuard<'static, ()>>
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
Locks this rwlock with shared read access, blocking the current thread until it can be acquired.
See RwLock::read
.
fn try_read(&'static self) -> TryLockResult<RwLockReadGuard<'static, ()>>
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
Attempts to acquire this lock with shared read access.
See RwLock::try_read
.
fn write(&'static self) -> LockResult<RwLockWriteGuard<'static, ()>>
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
Locks this rwlock with exclusive write access, blocking the current thread until it can be acquired.
See RwLock::write
.
fn try_write(&'static self) -> TryLockResult<RwLockWriteGuard<'static, ()>>
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
Attempts to lock this rwlock with exclusive write access.
See RwLock::try_write
.
unsafe fn destroy(&'static self)
: the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
static_rwlock
#27717): the lazy-static crate suffices for static sync primitives and eventually this type shouldn't be necessary as RwLock::new
in a static should suffice
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.