-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
For some reason, adding a function to the queue causes the previous one to end. Am I doing something wrong or is this intended? How can I get the expected result?
import 'dart:async';
import 'dart:developer';
import 'package:queue/src/dart_queue_base.dart';
void main() async {
final Queue queue = Queue(delay: Duration(seconds: 6));
Future<void> wait(String a) async {
await queue.add(() => Future.delayed(Duration(milliseconds: 100)));
log('$a ${DateTime.now()}');
};
wait('a');
wait('b');
await Future.delayed(Duration(milliseconds: 100));
wait('c');
await Future.delayed(Duration(seconds: 10));
}
result:
[log] a 2025-03-06 16:12:24.307348
[log] b 2025-03-06 16:12:24.412779
[log] c 2025-03-06 16:12:30.432560
excepted:
[log] a 2025-03-06 16:12:24.307348
[log] b 2025-03-06 16:12:30.332560
[log] c 2025-03-06 16:12:36.432560
Metadata
Metadata
Assignees
Labels
No labels