Skip to main content

SharedRWLock

Struct SharedRWLock 

Source
pub struct SharedRWLock { /* private fields */ }

Implementations§

Source§

impl SharedRWLock

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self, RWLockError>

Obtain the lock at path, initializing it if it does not yet exist and attaching to it if it does. Attaching leaves a held writer flag in place. reset reinitializes.

Source

pub fn reset(path: impl AsRef<Path>) -> Result<Self, RWLockError>

Reinitialize the lock at path: the header is truncated and zeroed, discarding any state a live holder owns. For a caller that owns the path.

Source

pub fn create_or_open(path: impl AsRef<Path>) -> Result<Self, RWLockError>

Open the lock at path, creating it if it does not exist, without a window in which two callers can both create it.

create truncates and zeroes the header, so a second caller running it against a live lock clears a writer flag another holder owns and mutual exclusion is silently lost. An exists-then-create check does not close that: the check and the create are separate steps. Here exactly one caller wins an exclusive create_new and initialises; the rest open and wait for the magic to appear.

Use this for any lock a peer may reach first. create stays the right call only when the caller knows it owns the path.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, RWLockError>

Source

pub fn try_read_lock(&self) -> Result<ReadGuard<'_>, RWLockError>

Try to acquire a read lock without blocking.

Source

pub fn read_lock(&self) -> ReadGuard<'_>

Acquire a read lock, blocking with backoff until available. Writer-priority: blocks if any writer is active OR waiting.

Source

pub fn try_write_lock(&self) -> Result<WriteGuard<'_>, RWLockError>

Try to acquire a write lock without blocking.

Source

pub fn write_lock(&self) -> WriteGuard<'_>

Acquire a write lock, blocking until available. Registers as “waiting” so new readers will block.

Source

pub fn reader_count(&self) -> u32

Number of active readers (observational; may race).

Source

pub fn has_writer(&self) -> bool

True if a writer currently holds the lock.

Source

pub fn waiting_writers(&self) -> u32

Number of writers currently waiting for the lock.

Source

pub fn release_read_for_blocking(&self)

Public hook for the BlockingRWLock wrapper to mirror the inner ReadGuard::drop semantics after the wrapper’s own guard runs (the wrapper mem::forgets the inner guard so it can interleave a wake call between the state release and the guard’s destructor).

Source

pub fn release_write_for_blocking(&self)

Public hook for the BlockingRWLock wrapper; mirror of WriteGuard::drop.

Source

pub fn flush(&self) -> Result<(), RWLockError>

Source

pub fn flush_async(&self) -> Result<(), RWLockError>

Trait Implementations§

Source§

impl AdaptiveInstance for SharedRWLock

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedRWLock

Source§

impl Sync for SharedRWLock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.