Struct GCDatapointState
pub struct GCDatapointState {
latest_value: DatapointBuffering,
has_data: AtomicBool,
}Expand description
A store for datapoints that are updated in realtime.
Fields§
§latest_value: DatapointBuffering§has_data: AtomicBoolImplementations§
§impl GCDatapointState
impl GCDatapointState
pub(crate) fn new(capacity: u64) -> Self
pub(crate) fn new(capacity: u64) -> Self
Creates a new datapoint state that keeps the last capacity values.
If the capacity is less than or equal to 1, it will behave as a realtime datapoint, just keeping the latest value.
Else, it will keep the last capacity values.
pub(crate) fn new_realtime() -> Self
pub(crate) fn new_realtime() -> Self
Creates a new datapoint state that just keeps the latest value.
pub fn clear(&mut self)
pub fn clear(&mut self)
Set’s the datapoint state to the default one.
pub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
This should be an atomic operation and is dependant on the crate::GCRealtimeDatabase.
This assumes that once the has_data flag is set to true, the value will not be changed.
It provides a way for the caller to check if the datapoint has been initialized without the need of synchronization mechanism.
pub fn update_value(&mut self, value: GCArc<GCDatapointValue>)
pub fn update_value(&mut self, value: GCArc<GCDatapointValue>)
Updates the value of the datapoint
pub fn get_buffered_data(
&self,
) -> Option<impl Iterator<Item = &GCArc<GCDatapointValue>>>
pub fn get_buffered_data( &self, ) -> Option<impl Iterator<Item = &GCArc<GCDatapointValue>>>
Returns the last n datapoints
pub fn get_latest_value(&self) -> &GCArc<GCDatapointValue>
pub fn get_latest_value(&self) -> &GCArc<GCDatapointValue>
Returns the latest value of the datapoint