Class SlidingRingWindow<T>
java.lang.Object
com.aizuda.snailjob.client.common.window.SlidingRingWindow<T>
- Type Parameters:
T- the type of elements maintained in the window
A sliding window implementation that maintains data in a ring buffer structure.
The window slides based on either time duration or threshold count, whichever comes first.
Key features:
- Thread-safe implementation using atomic operations
- Supports both time-based and count-based window sliding
- Uses a ring buffer to efficiently manage window segments
- Allows multiple listeners to be notified when window data is emitted
-
Constructor Summary
ConstructorsConstructorDescriptionSlidingRingWindow(int ringSize, Duration duration, Integer totalThreshold, List<Listener<T>> listener) SlidingRingWindow(int ringSize, Duration duration, Integer totalThreshold, List<Listener<T>> listener, ScheduledExecutorService scheduler) -
Method Summary
-
Constructor Details
-
SlidingRingWindow
-
SlidingRingWindow
-
SlidingRingWindow
-
-
Method Details
-
shutdown
public void shutdown() -
add
Adds an element to the current window.This operation may trigger window sliding if either:
- The current window's time has expired
- The current window's element count has reached the threshold
- Parameters:
data- the element to be added to the window
-