File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/// Serializes operations without letting a failed operation poison later work.
22class SerialQueue {
3- Future <void > _tail = Future < void >. value () ;
3+ Future <void >? _tail;
44
55 Future <T > run <T >(Future <T > Function () operation) {
6- final result = _tail.then ((_) => operation ());
7- _tail = result.then <void >((_) {}, onError: (Object _, StackTrace _) {});
6+ final result = (_tail ?? Future <void >.value ()).then ((_) => operation ());
7+ late final Future <void > tail;
8+ void release () {
9+ // An idle queue must not retain a completed future's scheduler/zone.
10+ // A later operation may already have replaced this tail.
11+ if (identical (_tail, tail)) _tail = null ;
12+ }
13+
14+ tail = result.then <void >(
15+ (_) => release (),
16+ onError: (Object _, StackTrace _) => release (),
17+ );
18+ _tail = tail;
819 return result;
920 }
1021}
Original file line number Diff line number Diff line change @@ -827,7 +827,7 @@ void main() {
827827 );
828828 await tester.pump ();
829829 await tester.pump ();
830- await recovery.started.future ;
830+ expect ( recovery.started.isCompleted, isTrue) ;
831831
832832 expect (find.text ('Finish setting up' ), findsOneWidget);
833833 expect (find.text ('Finishing setup…' ), findsOneWidget);
@@ -893,7 +893,7 @@ void main() {
893893 );
894894 await tester.pump ();
895895 await tester.pump ();
896- await recovery.started.future ;
896+ expect ( recovery.started.isCompleted, isTrue) ;
897897
898898 recovery.completeError (Exception ('relay did not respond' ));
899899 await tester.pumpAndSettle ();
You can’t perform that action at this time.
0 commit comments