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

public class SlidingRingWindow<T> extends Object
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 Details

  • Method Details

    • shutdown

      public void shutdown()
    • add

      public void add(T data)
      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