QueueStrategy enum
Queue strategy for task execution
Determines the order in which queued tasks are executed when concurrency slots become available.
Example:
// Use priority-based execution
final limit = fLimit(2, queueStrategy: QueueStrategy.priority);
limit(() async => print('low'), priority: 1);
limit(() async => print('high'), priority: 10);
// Output: high, low
Values
- fifo → const QueueStrategy
-
First In, First Out (default)
Tasks are executed in the order they were added to the queue. This provides fair execution for all tasks.
- lifo → const QueueStrategy
-
Last In, First Out (stack-like behavior)
The most recently added task executes first. Useful for cache-like scenarios where newer data is more important.
- priority → const QueueStrategy
-
Priority-based execution
Tasks with higher priority values execute first. When priorities are equal, tasks execute in FIFO order.
- alternating → const QueueStrategy
-
Alternating between head and tail
Alternates between taking tasks from the front and back of the queue. Provides fair scheduling for both ends of the queue.
Example:
final limit = fLimit(1, queueStrategy: QueueStrategy.alternating); for (int i = 0; i < 5; i++) { limit(() async => print(i)); } // Output order: 0, 4, 1, 3, 2 - random → const QueueStrategy
-
Random selection from queue
Selects a random task from the queue each time a slot becomes available. Useful for load balancing and fair distribution across all queued tasks.
Example:
final limit = fLimit(1, queueStrategy: QueueStrategy.random); for (int i = 0; i < 5; i++) { limit(() async => print(i)); } // Output order: random (e.g., 3, 1, 4, 0, 2)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
QueueStrategy> - A constant List of the values in this enum, in order of their declaration.