A class in Alta.Api.Client, Alta.Api.Client.LowLevel.
Two queues that swap: entries collect in one until a timer runs out or it is full, then it is passed to ProcessQueue and the other takes new entries. Used by ApiBatchRequestService (30 s, 100 entries).
Constructors
| Member | What it is |
|---|
DoubleBufferedQueue(int lifetimeMs, int maxEntries) | Creates a DoubleBufferedQueue from lifetimeMs and maxEntries. |
Fields
7 private and internal fields
| Member | What it is |
|---|
private DoubleBufferedQueue<T> activeQueue | Which queue takes new entries. |
private readonly object enqueueLock | Lock held while adding an entry. |
private readonly Queue<T> primaryQueue | The first of the two queues. |
private readonly int queueMaxEntries | Entry count above which a queue is flushed early. |
private readonly Timer queueTimer | Timer that flushes the active queue after the lifetime set in the constructor. |
private readonly Queue<T> secondaryQueue | The second of the two queues. |
private readonly object swapLock | Lock held while swapping and flushing. |
Properties
| Member | What it is |
|---|
Action<IEnumerable<T>> ProcessQueue { get; set; } | Callback given the full or expired queue. |
Methods
| Member | What it is |
|---|
void Enqueue(T entry) | Adds an entry to the active queue, flushing first if it is full, and starts the timer. |
5 private and internal methods
| Member | What it is |
|---|
private bool IsQueueFull(Queue<T> queue) | True when the queue holds more than queueMaxEntries. |
private void OnQueueExpired(object sender, ElapsedEventArgs e) | Swaps the active queue, passes the old one to ProcessQueue and stops the timer. Nothing here clears the old queue. |
private void OnQueueExpired() | Swaps the active queue, passes the old one to ProcessQueue and stops the timer. Nothing here clears the old queue. |
private void SwapActiveQueue() | Switches which queue takes new entries. |
private async void WatchActiveQueue() | Starts the timer if it is not running. |
Used in
Members of other types that take, return or hold a DoubleBufferedQueue<T>: