Skip to content

Commit e5c4c61

Browse files
committed
Use onWritable watcher instead of repeat
The behavior of repeat with a 0 timeout is unpredictable in various loop implementations.
1 parent 7935564 commit e5c4c61

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Test.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1224,16 +1224,16 @@ function testDeferEnabledInNextTick() {
12241224

12251225
$invoked = 0;
12261226

1227-
$repeat = $this->loop->repeat($delay = 0, function () use (&$invoked) {
1227+
$watcher = $this->loop->onWritable(STDOUT, function () use (&$invoked) {
12281228
$invoked++;
12291229
});
12301230

12311231
$tick();
12321232
$tick();
12331233
$tick();
12341234

1235-
$this->loop->disable($repeat);
1236-
$this->loop->enable($repeat);
1235+
$this->loop->disable($watcher);
1236+
$this->loop->enable($watcher);
12371237
$tick(); // disable + immediate enable after a tick should have no effect either
12381238

12391239
$this->assertEquals(4, $invoked);

0 commit comments

Comments
 (0)