Skip to content

ExtEvLoop: Add new ExtEvLoop (PECL source ext-ev) #12

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 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Docblock fixes
- Change `stream` and `numeric` to valid phpdoc internal types
- Add some docs to TimerInterface and Timer
  • Loading branch information
DaveRandom committed Sep 15, 2014
commit a496c635bed51378d71fed733629ef15a9fe080c
8 changes: 4 additions & 4 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ private function scheduleTimer(TimerInterface $timer)
/**
* Create a new ext-event Event object, or update the existing one.
*
* @param stream $stream
* @param integer $flag Event::READ or Event::WRITE
* @param resource $stream
* @param integer $flag Event::READ or Event::WRITE
*/
private function subscribeStreamEvent($stream, $flag)
{
Expand All @@ -263,8 +263,8 @@ private function subscribeStreamEvent($stream, $flag)
* Update the ext-event Event object for this stream to stop listening to
* the given event type, or remove it entirely if it's no longer needed.
*
* @param stream $stream
* @param integer $flag Event::READ or Event::WRITE
* @param resource $stream
* @param integer $flag Event::READ or Event::WRITE
*/
private function unsubscribeStreamEvent($stream, $flag)
{
Expand Down
8 changes: 4 additions & 4 deletions src/LibEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ private function scheduleTimer(TimerInterface $timer)
/**
* Create a new ext-libevent event resource, or update the existing one.
*
* @param stream $stream
* @param integer $flag EV_READ or EV_WRITE
* @param resource $stream
* @param integer $flag EV_READ or EV_WRITE
*/
private function subscribeStreamEvent($stream, $flag)
{
Expand Down Expand Up @@ -267,8 +267,8 @@ private function subscribeStreamEvent($stream, $flag)
* Update the ext-libevent event resource for this stream to stop listening to
* the given event type, or remove it entirely if it's no longer needed.
*
* @param stream $stream
* @param integer $flag EV_READ or EV_WRITE
* @param resource $stream
* @param integer $flag EV_READ or EV_WRITE
*/
private function unsubscribeStreamEvent($stream, $flag)
{
Expand Down
18 changes: 9 additions & 9 deletions src/LoopInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ interface LoopInterface
/**
* Register a listener to be notified when a stream is ready to read.
*
* @param stream $stream The PHP stream resource to check.
* @param resource $stream The PHP stream resource to check.
* @param callable $listener Invoked when the stream is ready.
*/
public function addReadStream($stream, callable $listener);

/**
* Register a listener to be notified when a stream is ready to write.
*
* @param stream $stream The PHP stream resource to check.
* @param resource $stream The PHP stream resource to check.
* @param callable $listener Invoked when the stream is ready.
*/
public function addWriteStream($stream, callable $listener);

/**
* Remove the read event listener for the given stream.
*
* @param stream $stream The PHP stream resource.
* @param resource $stream The PHP stream resource.
*/
public function removeReadStream($stream);

/**
* Remove the write event listener for the given stream.
*
* @param stream $stream The PHP stream resource.
* @param resource $stream The PHP stream resource.
*/
public function removeWriteStream($stream);

/**
* Remove all listeners for the given stream.
*
* @param stream $stream The PHP stream resource.
* @param resource $stream The PHP stream resource.
*/
public function removeStream($stream);

Expand All @@ -49,8 +49,8 @@ public function removeStream($stream);
* The execution order of timers scheduled to execute at the same time is
* not guaranteed.
*
* @param numeric $interval The number of seconds to wait before execution.
* @param callable $callback The callback to invoke.
* @param int|float $interval The number of seconds to wait before execution.
* @param callable $callback The callback to invoke.
*
* @return TimerInterface
*/
Expand All @@ -62,8 +62,8 @@ public function addTimer($interval, callable $callback);
* The execution order of timers scheduled to execute at the same time is
* not guaranteed.
*
* @param numeric $interval The number of seconds to wait before execution.
* @param callable $callback The callback to invoke.
* @param int|float $interval The number of seconds to wait before execution.
* @param callable $callback The callback to invoke.
*
* @return TimerInterface
*/
Expand Down
33 changes: 33 additions & 0 deletions src/Timer/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ class Timer implements TimerInterface
protected $periodic;
protected $data;

/**
* Constructor initializes the fields of the Timer
*
* @param LoopInterface $loop The loop with which this timer is associated
* @param float $interval The interval after which this timer will execute, in seconds
* @param callable $callback The callback that will be executed when this timer elapses
* @param bool $periodic Whether the time is periodic
* @param mixed $data Arbitrary data associated with timer
*/
public function __construct(LoopInterface $loop, $interval, callable $callback, $periodic = false, $data = null)
{
if ($interval < self::MIN_INTERVAL) {
Expand All @@ -27,41 +36,65 @@ public function __construct(LoopInterface $loop, $interval, callable $callback,
$this->data = null;
}

/**
* {@inheritdoc}
*/
public function getLoop()
{
return $this->loop;
}

/**
* {@inheritdoc}
*/
public function getInterval()
{
return $this->interval;
}

/**
* {@inheritdoc}
*/
public function getCallback()
{
return $this->callback;
}

/**
* {@inheritdoc}
*/
public function setData($data)
{
$this->data = $data;
}

/**
* {@inheritdoc}
*/
public function getData()
{
return $this->data;
}

/**
* {@inheritdoc}
*/
public function isPeriodic()
{
return $this->periodic;
}

/**
* {@inheritdoc}
*/
public function isActive()
{
return $this->loop->isTimerActive($this);
}

/**
* {@inheritdoc}
*/
public function cancel()
{
$this->loop->cancelTimer($this);
Expand Down
47 changes: 47 additions & 0 deletions src/Timer/TimerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,61 @@

namespace React\EventLoop\Timer;

use React\EventLoop\LoopInterface;

interface TimerInterface
{
/**
* Get the loop with which this timer is associated

* @return LoopInterface
*/
public function getLoop();

/**
* Get the interval after which this timer will execute, in seconds
*
* @return float
*/
public function getInterval();

/**
* Get the callback that will be executed when this timer elapses
*
* @return callable
*/
public function getCallback();

/**
* Set arbitrary data associated with timer
*
* @param mixed $data
*/
public function setData($data);

/**
* Get arbitrary data associated with timer
*
* @return mixed
*/
public function getData();

/**
* Determine whether the time is periodic
*
* @return bool
*/
public function isPeriodic();

/**
* Determine whether the time is active
*
* @return bool
*/
public function isActive();

/**
* Cancel this timer
*/
public function cancel();
}
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