Skip to content

Event config #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add config option to ExtEventLoop to support readable streams via FEA…
…TURE_FDS
  • Loading branch information
steverhoades committed Aug 20, 2014
commit e4d6c7b3adf25410c3dc302463bbd96bf59275bc
5 changes: 3 additions & 2 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Event;
use EventBase;
use EventConfig as EventBaseConfig;
use React\EventLoop\Tick\FutureTickQueue;
use React\EventLoop\Tick\NextTickQueue;
use React\EventLoop\Timer\Timer;
Expand All @@ -27,9 +28,9 @@ class ExtEventLoop implements LoopInterface
private $writeListeners = [];
private $running;

public function __construct()
public function __construct(EventBaseConfig $config = null)
{
$this->eventBase = new EventBase();
$this->eventBase = new EventBase($config);
$this->nextTickQueue = new NextTickQueue($this);
$this->futureTickQueue = new FutureTickQueue($this);
$this->timerEvents = new SplObjectStorage();
Expand Down
36 changes: 34 additions & 2 deletions tests/ExtEventLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

class ExtEventLoopTest extends AbstractLoopTest
{
public function createLoop()
public function setUp()
{
$this->loop = $this->createLoop();
}

public function createLoop($readStreamCompatible = false)
{
if ('Linux' === PHP_OS && !extension_loaded('posix')) {
$this->markTestSkipped('libevent tests skipped on linux due to linux epoll issues.');
Expand All @@ -16,7 +21,13 @@ public function createLoop()
$this->markTestSkipped('ext-event tests skipped because ext-event is not installed.');
}

return new ExtEventLoop();
$cfg = null;
if($readStreamCompatible) {
$cfg = new \EventConfig();
$cfg->requireFeatures(\EventConfig::FEATURE_FDS);
}

return new ExtEventLoop($cfg);
}

public function createStream()
Expand Down Expand Up @@ -56,4 +67,25 @@ public function writeToStream($stream, $content)

fwrite($stream, $content);
}

/**
* @group epoll-readable-error
*/
public function testCanUseReadableStreamWithFeatureFds()
{
$this->loop = $this->createLoop(true);

$input = fopen('php://temp/maxmemory:0', 'r+');

fwrite($input, 'x');
ftruncate($input, 0);

$this->loop->addReadStream($input, $this->expectCallableExactly(2));

$this->writeToStream($input, "foo\n");
$this->loop->tick();

$this->writeToStream($input, "bar\n");
$this->loop->tick();
}
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy