dynamic_parallel_queue 1.0.0 copy "dynamic_parallel_queue: ^1.0.0" to clipboard
dynamic_parallel_queue: ^1.0.0 copied to clipboard

outdated

A easy to use and dynamic parallel queue.

Dynamic Parallel Queue #

Features #

Easy to use(so, no example project folder), Efficient, Pure

Getting started #

import 'package:dynamic_parallel_queue/dynamic_parallel_queue.dart';

Usage #

void main() async {
  final queue = Queue(parallel: 1); // Serial queue

  queue.add(() async {
    await Future.delayed(Duration(milliseconds: 100));
    return 100;
  }).then((value) {
    print('task done, value:$value');
  });

  /// You can change the parallel value of the queue at any time
  /// Including while there are still tasks executing
  queue.parallel = 10; // Change to parallel queue

  List.generate(20, (index) async {
    index += 1;
    final milliseconds = index * 10;
    final value = await queue.add(() async {
      await Future.delayed(Duration(milliseconds: milliseconds));
      return milliseconds;
    });
    print('task $index done, value:$value');
  });


  /// Clear all pending tasks
  // queue.clear();

  /// Wait for the queue to complete
  await queue.whenComplete();
  print('All done');
}
4
likes
0
points
57
downloads

Publisher

unverified uploader

Weekly Downloads

A easy to use and dynamic parallel queue.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on dynamic_parallel_queue