BufferingPeriodicStreamProbe
A probe that buffers a bufferingStream in sampling windows.
It emits one measurement per window. Uses a PeriodicSamplingConfiguration: every PeriodicSamplingConfiguration.interval it calls onSamplingStart and listens to bufferingStream for PeriodicSamplingConfiguration.duration. Each event goes to onSamplingData. When the window ends, it calls onSamplingEnd and adds the result of getMeasurement.
Unlike BufferingIntervalStreamProbe, it listens to bufferingStream only inside sampling windows. See LightProbe for an example, which turns the light readings of each window into one AmbientLight measurement.
- Inheritance
-
- Object
- AbstractExecutor<
Measure> - Probe
- StreamProbe
- PeriodicStreamProbe
- BufferingPeriodicStreamProbe
- Implementers
Constructors
BufferingPeriodicStreamProbe
Properties
bufferingStream
The stream of events to buffer. Implemented by subclasses.
stream
The stream of Measurements to forward. Implemented by subclasses.
Read on the first resume after creation or a pause.
Methods
getMeasurement
Returns the Measurement for the last sampling window.
Implemented by subclasses.
Can return null if no data is available. Can return an Error if an error occurs.
onPause
Called by pause. Returns true if successfully paused.
If false, the state is not changed.
onResume
Called by resume. Returns true if successfully resumed.
If false, the executor moves to ExecutorState.PausedButShouldBeResumed.
onSamplingData
- dynamic event
Called for each event on bufferingStream; buffers it.
onSamplingEnd
Called when a sampling window ends, before getMeasurement.
onSamplingStart
Called when a sampling window starts, before listening.