Skip to content

Commit d82fdbf

Browse files
committed
Merge pull request #11 from steverhoades/event-config
Event config
2 parents 27c34c4 + 21eb897 commit d82fdbf

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/ExtEventLoop.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Event;
66
use EventBase;
7+
use EventConfig as EventBaseConfig;
78
use React\EventLoop\Tick\FutureTickQueue;
89
use React\EventLoop\Tick\NextTickQueue;
910
use React\EventLoop\Timer\Timer;
@@ -27,9 +28,9 @@ class ExtEventLoop implements LoopInterface
2728
private $writeListeners = [];
2829
private $running;
2930

30-
public function __construct()
31+
public function __construct(EventBaseConfig $config = null)
3132
{
32-
$this->eventBase = new EventBase();
33+
$this->eventBase = new EventBase($config);
3334
$this->nextTickQueue = new NextTickQueue($this);
3435
$this->futureTickQueue = new FutureTickQueue($this);
3536
$this->timerEvents = new SplObjectStorage();

tests/ExtEventLoopTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ExtEventLoopTest extends AbstractLoopTest
88
{
9-
public function createLoop()
9+
public function createLoop($readStreamCompatible = false)
1010
{
1111
if ('Linux' === PHP_OS && !extension_loaded('posix')) {
1212
$this->markTestSkipped('libevent tests skipped on linux due to linux epoll issues.');
@@ -16,7 +16,13 @@ public function createLoop()
1616
$this->markTestSkipped('ext-event tests skipped because ext-event is not installed.');
1717
}
1818

19-
return new ExtEventLoop();
19+
$cfg = null;
20+
if($readStreamCompatible) {
21+
$cfg = new \EventConfig();
22+
$cfg->requireFeatures(\EventConfig::FEATURE_FDS);
23+
}
24+
25+
return new ExtEventLoop($cfg);
2026
}
2127

2228
public function createStream()
@@ -56,4 +62,25 @@ public function writeToStream($stream, $content)
5662

5763
fwrite($stream, $content);
5864
}
65+
66+
/**
67+
* @group epoll-readable-error
68+
*/
69+
public function testCanUseReadableStreamWithFeatureFds()
70+
{
71+
$this->loop = $this->createLoop(true);
72+
73+
$input = fopen('php://temp/maxmemory:0', 'r+');
74+
75+
fwrite($input, 'x');
76+
ftruncate($input, 0);
77+
78+
$this->loop->addReadStream($input, $this->expectCallableExactly(2));
79+
80+
$this->writeToStream($input, "foo\n");
81+
$this->loop->tick();
82+
83+
$this->writeToStream($input, "bar\n");
84+
$this->loop->tick();
85+
}
5986
}

0 commit comments

Comments
 (0)