pub trait CounterFn {
    fn increment(&self, value: u64);
    fn absolute(&self, value: u64);
}
Expand description

A counter handler.

Required Methods

Increments the counter by the given amount.

Returns the previous value.

Sets the counter to at least the given amount.

This is intended to support use cases where multiple callers are attempting to synchronize this counter with an external counter that they have no control over. As multiple callers may read that external counter, and attempt to set it here, there could be reordering issues where a caller attempts to set an older (smaller) value after the counter has been updated to the latest (larger) value.

This method must cope with those cases. An example of doing so atomically can be found in AtomicCounter.

Returns the previous value.

Implementations on Foreign Types

Implementors