Skip to content

Implement Eventloop based on pecl/event #177

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

Closed
wants to merge 8 commits into from
Closed
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
Prev Previous commit
Next Next commit
Fixed a warning
  • Loading branch information
csaoh committed Apr 22, 2013
commit d5ca1168c4bae28baa75626fbb9094b8d121aed3
1 change: 1 addition & 0 deletions src/React/EventLoop/EventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
}

$timer = new Timer($this, $interval, $callback, $periodic);
$flags = 0;
if ($periodic == true)
$flags = \Event::PERSIST;
$resource = new \Event($this->base, -1, $flags | \Event::TIMEOUT, $callback);
Expand Down
21 changes: 11 additions & 10 deletions tests/React/Tests/EventLoop/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ abstract class AbstractLoopTest extends TestCase
public function setUp()
{
$this->loop = $this->createLoop();
touch("testfile");
}

abstract public function createLoop();

public function testAddReadStream()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

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

Expand All @@ -32,7 +33,7 @@ public function testAddReadStream()

public function testAddWriteStream()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addWriteStream($input, $this->expectCallableExactly(2));
$this->loop->tick();
Expand All @@ -41,7 +42,7 @@ public function testAddWriteStream()

public function testRemoveReadStreamInstantly()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addReadStream($input, $this->expectCallableNever());
$this->loop->removeReadStream($input);
Expand All @@ -53,7 +54,7 @@ public function testRemoveReadStreamInstantly()

public function testRemoveReadStreamAfterReading()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addReadStream($input, $this->expectCallableOnce());

Expand All @@ -70,7 +71,7 @@ public function testRemoveReadStreamAfterReading()

public function testRemoveWriteStreamInstantly()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addWriteStream($input, $this->expectCallableNever());
$this->loop->removeWriteStream($input);
Expand All @@ -79,7 +80,7 @@ public function testRemoveWriteStreamInstantly()

public function testRemoveWriteStreamAfterWriting()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addWriteStream($input, $this->expectCallableOnce());
$this->loop->tick();
Expand All @@ -90,7 +91,7 @@ public function testRemoveWriteStreamAfterWriting()

public function testRemoveStreamInstantly()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addReadStream($input, $this->expectCallableNever());
$this->loop->addWriteStream($input, $this->expectCallableNever());
Expand All @@ -103,7 +104,7 @@ public function testRemoveStreamInstantly()

public function testRemoveStream()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$this->loop->addReadStream($input, $this->expectCallableOnce());
$this->loop->addWriteStream($input, $this->expectCallableOnce());
Expand All @@ -128,7 +129,7 @@ public function emptyRunShouldSimplyReturn()
/** @test */
public function runShouldReturnWhenNoMoreFds()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$loop = $this->loop;
$this->loop->addReadStream($input, function ($stream) use ($loop) {
Expand All @@ -144,7 +145,7 @@ public function runShouldReturnWhenNoMoreFds()
/** @test */
public function stopShouldStopRunningLoop()
{
$input = fopen('php://temp', 'r+');
$input = fopen('testfile', 'r+');

$loop = $this->loop;
$this->loop->addReadStream($input, function ($stream) use ($loop) {
Expand Down
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