Struct uwheel::wheels::read::ReaderWheel

source ·
pub struct ReaderWheel<A>
where A: Aggregator,
{ /* private fields */ }
Expand description

A reader wheel containing a hierarchical aggregate wheel Haw backed by interior mutability.

By default allows a single reader using RefCell, and multiple-readers with the sync flag enabled using parking_lot

Implementations§

source§

impl<A> ReaderWheel<A>
where A: Aggregator,

source

pub fn new(time: u64) -> Self

Creates a new Wheel starting from the given time with default configuration

Time is represented as milliseconds

source

pub fn with_conf(conf: HawConf) -> Self

Creates a new Wheel starting from the given configuration

source

pub fn from_delta_state(state: DeltaState<A::PartialAggregate>) -> Self

Creates a new Wheel from a set of deltas

source

pub fn delta_state(&self) -> DeltaState<A::PartialAggregate>

Returns the current Delta State for the Reader Wheel

source

pub fn len(&self) -> usize

Returns the number of wheel slots used

source

pub fn is_empty(&self) -> bool

Returns true if the internal wheel time has never been advanced

source

pub fn is_full(&self) -> bool

Returns true if all slots in the hierarchy are utilised

source

pub fn remaining_ticks(&self) -> u64

Returns how many ticks (seconds) are left until the wheel is fully utilised

source

pub fn to_prefix_wheels(&self)

Converts all wheels to be prefix-enabled

See Haw::to_prefix_wheels for more information

source

pub fn to_simd_wheels(&self)

Organizes all wheels to be contigious to support explicit SIMD execution.

See Haw::to_simd_wheels for more information

source

pub fn current_time_in_cycle(&self) -> Duration

Returns Duration that represents where the wheel currently is in its cycle

source

pub fn schedule_once( &self, at: u64, f: impl Fn(&Haw<A>) + 'static ) -> Result<(), TimerError<TimerAction<A>>>

Available on crate feature timer only.

Schedules a timer to fire once the given time has been reached

See Haw::schedule_once for more information.

source

pub fn schedule_repeat( &self, at: u64, interval: Duration, f: impl Fn(&Haw<A>) + 'static ) -> Result<(), TimerError<TimerAction<A>>>

Available on crate feature timer only.

Schedules a timer to fire repeatedly

See Haw::schedule_repeat for more information.

source

pub fn delta_advance( &self, deltas: impl IntoIterator<Item = Option<A::PartialAggregate>> )

Advances the wheel by applying a set of deltas, each representing the lowest unit.

See Haw::delta_advance for more information.

source

pub fn clear(&self)

Clears the state of all wheels

source

pub fn watermark(&self) -> u64

Return the current watermark as milliseconds for this wheel

source

pub fn interval_and_lower(&self, dur: Duration) -> Option<A::Aggregate>

Returns the aggregate in the given time interval

source

pub fn interval(&self, dur: Duration) -> Option<A::PartialAggregate>

Returns the partial aggregate in the given time interval

See Haw::interval for more information.

source

pub fn interval_with_ops( &self, dur: Duration ) -> (Option<A::PartialAggregate>, usize)

Returns the partial aggregate in the given time interval and the number of combine operations

source

pub fn combine_range( &self, range: impl Into<WheelRange> ) -> Option<A::PartialAggregate>

Combines partial aggregates within the given date range [start, end) into a final partial aggregate

Returns None if the range cannot be answered by the wheel

See Haw::combine_range for more information.

source

pub fn combine_range_and_lower( &self, range: impl Into<WheelRange> ) -> Option<A::PartialAggregate>

Combines aggregates within the given date range [start, end) into a final partial aggregate

Returns None if the range cannot be answered by the wheel

See Haw::combine_range_and_lower for more information.

source

pub fn range( &self, range: impl Into<WheelRange> ) -> Option<Vec<(u64, A::PartialAggregate)>>

Returns partial aggregates within the given date range [start, end) using the lowest granularity

Returns None if the range cannot be answered by the wheel

See Haw::range for more information.

source

pub fn range_and_lower( &self, range: impl Into<WheelRange> ) -> Option<Vec<(u64, A::Aggregate)>>

Returns aggregates within the given date range [start, end) using the lowest granularity

Returns None if the range cannot be answered by the wheel

See Haw::range_and_lower for more information.

source

pub fn landmark(&self) -> Option<A::PartialAggregate>

Executes a Landmark Window that combines total partial aggregates across all wheels

See Haw::landmark for more information.

source

pub fn merge(&self, other: &Self)

Merges another ReaderWheel into this one

source

pub fn as_ref(&self) -> HawRef<'_, A>

Returns a reference to the internal Haw data structure

Trait Implementations§

source§

impl<A> Clone for ReaderWheel<A>
where A: Aggregator + Clone,

source§

fn clone(&self) -> ReaderWheel<A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'de, A> Deserialize<'de> for ReaderWheel<A>
where A: Aggregator + Default,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A: Aggregator> From<Haw<A>> for ReaderWheel<A>

source§

fn from(value: Haw<A>) -> Self

Converts to this type from the input type.
source§

impl<A> Serialize for ReaderWheel<A>
where A: Aggregator + Default,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<A> Freeze for ReaderWheel<A>

§

impl<A> !RefUnwindSafe for ReaderWheel<A>

§

impl<A> !Send for ReaderWheel<A>

§

impl<A> !Sync for ReaderWheel<A>

§

impl<A> Unpin for ReaderWheel<A>

§

impl<A> !UnwindSafe for ReaderWheel<A>

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> MutablePartialAggregateType for T
where T: Clone + Serialize + for<'a> Deserialize<'a> + 'static,