File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:async' ;
1
2
import 'dart:convert' ;
2
3
import 'dart:io' ;
3
4
@@ -509,8 +510,37 @@ class UpdateMachine {
509
510
final String queueId;
510
511
int lastEventId;
511
512
513
+ Completer <void >? _debugLoopSignal;
514
+
515
+ /// In debug mode, causes the polling loop to pause before the next
516
+ /// request and wait for [debugAdvanceLoop] to be called.
517
+ void debugPauseLoop () {
518
+ assert ((){
519
+ assert (_debugLoopSignal == null );
520
+ _debugLoopSignal = Completer ();
521
+ return true ;
522
+ }());
523
+ }
524
+
525
+ /// In debug mode, after a call to [debugPauseLoop] , causes the
526
+ /// polling loop to make one more request and then pause again.
527
+ void debugAdvanceLoop () {
528
+ assert ((){
529
+ _debugLoopSignal! .complete ();
530
+ return true ;
531
+ }());
532
+ }
533
+
512
534
void poll () async {
513
535
while (true ) {
536
+ if (_debugLoopSignal != null ) {
537
+ await _debugLoopSignal! .future;
538
+ assert (() {
539
+ _debugLoopSignal = Completer ();
540
+ return true ;
541
+ }());
542
+ }
543
+
514
544
final result = await getEvents (store.connection,
515
545
queueId: queueId, lastEventId: lastEventId);
516
546
// TODO handle errors on get-events; retry with backoff
You can’t perform that action at this time.
0 commit comments