pub struct SubscriberPosition { /* private fields */ }Expand description
MMF-backed monotonically-increasing consumer position counter.
Implementations§
Source§impl SubscriberPosition
impl SubscriberPosition
Sourcepub fn create(path: impl AsRef<Path>, initial: u64) -> Result<Self, Error>
pub fn create(path: impl AsRef<Path>, initial: u64) -> Result<Self, Error>
Create a new position counter at path initialised to
initial.
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
Open an existing position counter at path for read/write.
Used by a subscriber restart path.
Sourcepub fn advance(&self, by: u64) -> u64
pub fn advance(&self, by: u64) -> u64
Advance the position by by. Returns the NEW position.
Atomic; safe for one subscriber to call concurrently with
another holder reading via get.
Sourcepub fn set(&self, new: u64)
pub fn set(&self, new: u64)
Set the position to new unconditionally. Used by restart
paths that want to reset rather than advance.
Sourcepub fn compare_and_set(&self, expected: u64, new: u64) -> Result<u64, u64>
pub fn compare_and_set(&self, expected: u64, new: u64) -> Result<u64, u64>
Compare-and-set semantics. Returns Ok(new) if the previous
value matched expected; Err(actual) otherwise.
Sourcepub fn counter_handle(&self) -> Arc<SharedAtomicU64> ⓘ
pub fn counter_handle(&self) -> Arc<SharedAtomicU64> ⓘ
Clone the underlying Arc<SharedAtomicU64> so a second
in-process holder can read the same counter cheaply.
Auto Trait Implementations§
impl Freeze for SubscriberPosition
impl RefUnwindSafe for SubscriberPosition
impl Send for SubscriberPosition
impl Sync for SubscriberPosition
impl Unpin for SubscriberPosition
impl UnsafeUnpin for SubscriberPosition
impl UnwindSafe for SubscriberPosition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more