Skip to main content

ConcurrentTracker

Trait ConcurrentTracker 

pub trait ConcurrentTracker:
    Send
    + Sync
    + 'static {
    type Guard: Send + 'static;
    type Error: Send + 'static;

    // Required method
    fn try_access(&self) -> Result<Self::Guard, Self::Error>;
}
Expand description

The tracker trait that can be implemented to provide custom concurrent input tracking.

By default ConcurrentCounter is provided, but in case you need multi-instance tracking, you can support that by implementing the ConcurrentTracker trait.

Required Associated Types§

type Guard: Send + 'static

The guard that is used to consume a resource and that is expected to release the resource when dropped.

type Error: Send + 'static

The error that is returned when the concurrent input limit is reached, which is also returned in case a used backoff failed.

Required Methods§

fn try_access(&self) -> Result<Self::Guard, Self::Error>

Try to access the resource, returning a guard if successful, or an error if the limit is reached.

When the limit is reached and a backoff is used in the parent structure, the backoff should tried to be used before returning the error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl ConcurrentTracker for ConcurrentCounter

§

type Guard = ConcurrentCounterGuard

§

type Error = LimitReached