File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -333,29 +333,30 @@ plan 55;
333
333
my $ trigger1 = Supplier. new ;
334
334
my $ trigger2 = Supplier. new ;
335
335
336
- my $ lock = Lock . new ;
337
- my $ cv1 = $ lock . condition ;
338
- my $ cv2 = $ lock . condition ;
336
+ my $ p1 = Promise . new ;
337
+ my $ p2 = Promise . new ;
338
+ my $ p3 = Promise . new ;
339
339
340
340
my $ s = supply {
341
341
whenever $ trigger1 -> $ value {
342
- $ lock . protect({ $ cv1 . signal; $ cv2 . wait });
342
+ $ p1 . keep (True );
343
+ await $ p2 ;
343
344
emit " a $ value" ;
344
345
}
345
346
whenever $ trigger2 -> $ value {
346
347
emit " the $ value" ;
348
+ $ p3 . keep (True );
347
349
}
348
350
}
349
351
350
352
my @ collected ;
351
353
$ s . tap ({ @ collected . push ($ _ ) });
352
354
353
355
start { $ trigger1 . emit (' bear' ); }
354
- $ lock . protect({ $ cv1 . wait }) ;
356
+ await $ p1 ;
355
357
start { $ trigger2 . emit (' wolf' ); }
356
- sleep 0.5 ;
357
- $ lock . protect({ $ cv2 . signal });
358
- sleep 0.5 ;
358
+ $ p2 . keep (True );
359
+ await $ p3 ;
359
360
360
361
is @ collected , [' a bear' , ' the wolf' ], ' Can only be in one whatever block at a time' ;
361
362
}
You can’t perform that action at this time.
0 commit comments