operation_queue

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

operation queue

Features #
An easy multi task utility that can control the number of concurrency.
Getting started #
Add the dependency in pubspec.yaml:
dependencies:
...
operation_queue: ^0.5.1
copied to clipboard
Usage #
/// 3 tasks can run concurrently.
/// Each task takes an integer as input and generates integers as output.
var opeartionQueue = OperationQueue<int, int>(
concurrency: 3,
task: (data) async* {
final startDate = DateTime.now();
for (var i = 0; i < data; i++) {
await Future.delayed(const Duration(milliseconds: 100));

// produce output
yield data*10;
}
});

void _heavyWork() async {

opeartionQueue.listen((event) {
print('output: $event.');
});

for (var count in [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12]) {
opeartionQueue.add(count);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.