pub struct Observer<E> { /* private fields */ }Expand description
Data structure used to handle publish/subscribe callbacks of specific type. Observers perform subscriber changes in thread-safe manner, using atomic hardware intrinsics.
Implementations§
Source§impl<E> Observer<E>
impl<E> Observer<E>
pub fn has_subscribers(&self) -> bool
Sourcepub fn clean(&self)
pub fn clean(&self)
Cleanup already released subscriptions. Whenever a Subscription is dropped, the callback is released. However, the weak reference to callback may still be kept around until it becomes touched by operations such as Observer::subscribe or Observer::callbacks.
This method allows to perform stale callback cleanup without waiting for callbacks to be visited.
Sourcepub fn subscribe<F>(&self, callback: F) -> Subscription
pub fn subscribe<F>(&self, callback: F) -> Subscription
Subscribes a callback parameter to a current Observer. Returns a subscription object which - when dropped - will unsubscribe current callback.
Trait Implementations§
impl<E> Send for Observer<E>where
E: Send,
impl<E> Sync for Observer<E>where
E: Sync,
Auto Trait Implementations§
impl<E> !Freeze for Observer<E>
impl<E> !RefUnwindSafe for Observer<E>
impl<E> !UnwindSafe for Observer<E>
impl<E> Unpin for Observer<E>
impl<E> UnsafeUnpin for Observer<E>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more