BatchQueue<T> class
A queue that collects items and processes them in batches.
The BatchQueue accumulates items of type T
and processes them in batches
either when:
- The number of items reaches batchSize
- A timeout of timeout milliseconds occurs after the first item is added
This is useful for optimizing operations that are more efficient when performed in batches, such as database operations or API calls.
Constructors
-
BatchQueue.new({required int batchSize, int timeout = 500, required BatchFunction<
T> executeBatch}) - Creates a new BatchQueue.
Properties
- batchSize → int
-
final
-
executeBatch
→ BatchFunction<
T> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeout → int
-
final
Methods
-
flush(
) → Future< void> - Processes all pending tasks in the queue immediately.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
submit(
T task) → void - Adds a task to the queue for batch processing.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited