Struct sgx_sync::MovableRwLock
source · [−]pub struct MovableRwLock(_);
Expand description
An SGX-based reader-writer lock.
This rwlock cleans up its resources in its Drop
implementation and may
safely be moved (when not borrowed).
This rwlock does not implement poisoning.
This is either a wrapper around LazyBox<imp::RwLock>
or imp::RwLock
,
depending on the platform. It is boxed on platforms where imp::RwLock
may
not be moved.
Implementations
sourceimpl MovableRwLock
impl MovableRwLock
sourcepub const fn new() -> MovableRwLock
pub const fn new() -> MovableRwLock
Creates a new reader-writer lock for use.
sourcepub fn read(&self)
pub fn read(&self)
Acquires shared access to the underlying lock, blocking the current thread to do so.
sourcepub fn try_read(&self) -> bool
pub fn try_read(&self) -> bool
Attempts to acquire shared access to this lock, returning whether it succeeded or not.
This function does not block the current thread.
sourcepub fn write(&self)
pub fn write(&self)
Acquires write access to the underlying lock, blocking the current thread to do so.
Behavior is undefined if the rwlock has been moved between this and any previous method call.
sourcepub fn try_write(&self) -> bool
pub fn try_write(&self) -> bool
Attempts to acquire exclusive access to this lock, returning whether it succeeded or not.
This function does not block the current thread.
Behavior is undefined if the rwlock has been moved between this and any previous method call.
sourcepub unsafe fn read_unlock(&self)
pub unsafe fn read_unlock(&self)
Unlocks previously acquired shared access to this lock.
Behavior is undefined if the current thread does not have shared access.
sourcepub unsafe fn write_unlock(&self)
pub unsafe fn write_unlock(&self)
Unlocks previously acquired exclusive access to this lock.
Behavior is undefined if the current thread does not currently have exclusive access.