8000 Documentation for Factory by clue · Pull Request #119 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

Documentation for Factory #119

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
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ $loop->run();
purposes.
3. The loop is run with a single `$loop->run()` call at the end of the program.

## Factory

The `Factory` class exists as a convenient way to pick the best available
[loop implementation)(#loop-implementation).

The `create(): LoopInterface` method can be used to create a new loop
instance:

```php
$loop = React\EventLoop\Factory::create();
```

This method always returns an instance implementing `LoopInterface`,
the actual loop implementation is an implementation detail.

This method should usually only be called once at the beginning of the program.

## Loop implementations

In addition to the interface there are the following implementations provided:
Expand Down
39 changes: 0 additions & 39 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ function ($signal) {
$this->createStreamCallback();
}

/**
* {@inheritdoc}
*/
public function addReadStream($stream, callable $listener)
{
$key = (int) $stream;
Expand All @@ -72,9 +69,6 @@ public function addReadStream($stream, callable $listener)
}
}

/**
* {@inheritdoc}
*/
public function addWriteStream($stream, callable $listener)
{
$key = (int) $stream;
Expand All @@ -85,9 +79,6 @@ public function addWriteStream($stream, callable $listener)
}
}

/**
* {@inheritdoc}
*/
public function removeReadStream($stream)
{
$key = (int) $stream;
Expand All @@ -98,9 +89,6 @@ public function removeReadStream($stream)
}
}

/**
* {@inheritdoc}
*/
public function removeWriteStream($stream)
{
$key = (int) $stream;
Expand All @@ -127,9 +115,6 @@ private function removeStream($stream)
}
}

/**
* {@inheritdoc}
*/
public function addTimer($interval, callable $callback)
{
$timer = new Timer($interval, $callback, false);
Expand All @@ -139,9 +124,6 @@ public function addTimer($interval, callable $callback)
return $timer;
}

/**
* {@inheritdoc}
*/
public function addPeriodicTimer($interval, callable $callback)
{
$timer = new Timer($interval, $callback, true);
Expand All @@ -151,9 +133,6 @@ public function addPeriodicTimer($interval, callable $callback)
return $timer;
}

/**
* {@inheritdoc}
*/
public function cancelTimer(TimerInterface $timer)
{
if ($this->isTimerActive($timer)) {
Expand All @@ -162,41 +141,26 @@ public function cancelTimer(TimerInterface $timer)
}
}

/**
* {@inheritdoc}
*/
public function isTimerActive(TimerInterface $timer)
{
return $this->timerEvents->contains($timer);
}

/**
* {@inheritdoc}
*/
public function futureTick(callable $listener)
{
$this->futureTickQueue->add($listener);
}

/**
* {@inheritdoc}
*/
public function addSignal($signal, callable $listener)
{
$this->signals->add($signal, $listener);
}

/**
* {@inheritdoc}
*/
public function removeSignal($signal, callable $listener)
{
$this->signals->remove($signal, $listener);
}

/**
* {@inheritdoc}
*/
public function run()
{
$this->running = true;
Expand All @@ -215,9 +179,6 @@ public function run()
}
}

/**
* {@inheritdoc}
*/
public function stop()
{
$this->running = false;
Expand Down
17 changes: 17 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@

namespace React\EventLoop;

/**
* The `Factory` class exists as a convenient way to pick the best available loop implementation.
*/
class Factory
{
/**
* Creates a new loop instance
*
* ```php
* $loop = React\EventLoop\Factory::create();
* ```
*
* This method always returns an instance implementing `LoopInterface`,
* the actual loop implementation is an implementation detail.
*
* This method should usually only be called once at the beginning of the program.
*
* @return LoopInterface
*/
public static function create()
{
// @codeCoverageIgnoreStart
Expand Down
39 changes: 0 additions & 39 deletions src/LibEvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ function ($signal) {
);
}

/**
* {@inheritdoc}
*/
public function addReadStream($stream, callable $listener)
{
if (isset($this->readEvents[(int) $stream])) {
Expand All @@ -73,9 +70,6 @@ public function addReadStream($stream, callable $listener)
$this->readEvents[(int) $stream] = $event;
}

/**
* {@inheritdoc}
*/
public function addWriteStream($stream, callable $listener)
{
if (isset($this->writeEvents[(int) $stream])) {
Expand All @@ -92,9 +86,6 @@ public function addWriteStream($stream, callable $listener)
$this->writeEvents[(int) $stream] = $event;
}

/**
* {@inheritdoc}
*/
public function removeReadStream($stream)
{
$key = (int) $stream;
Expand All @@ -105,9 +96,6 @@ public function removeReadStream($stream)
}
}

/**
* {@inheritdoc}
*/
public function removeWriteStream($stream)
{
$key = (int) $stream;
Expand All @@ -118,9 +106,6 @@ public function removeWriteStream($stream)
}
}

/**
* {@inheritdoc}
*/
public function addTimer($interval, callable $callback)
{
$timer = new Timer( $interval, $callback, false);
Expand All @@ -140,9 +125,6 @@ public function addTimer($interval, callable $callback)
return $timer;
}

/**
* {@inheritdoc}
*/
public function addPeriodicTimer($interval, callable $callback)
{
$timer = new Timer($interval, $callback, true);
Expand All @@ -158,9 +140,6 @@ public function addPeriodicTimer($interval, callable $callback)
return $timer;
}

/**
* {@inheritdoc}
*/
public function cancelTimer(TimerInterface $timer)
{
if (isset($this->timerEvents[$timer])) {
Expand All @@ -169,41 +148,26 @@ public function cancelTimer(TimerInterface $timer)
}
}

/**
* {@inheritdoc}
*/
public function isTimerActive(TimerInterface $timer)
{
return $this->timerEvents->contains($timer);
}

/**
* {@inheritdoc}
*/
public function futureTick(callable $listener)
{
$this->futureTickQueue->add($listener);
}

/**
* {@inheritdoc}
*/
public function addSignal($signal, callable $listener)
{
$this->signals->add($signal, $listener);
}

/**
* {@inheritdoc}
*/
public function removeSignal($signal, callable $listener)
{
$this->signals->remove($signal, $listener);
}

/**
* {@inheritdoc}
*/
public function run()
{
$this->running = true;
Expand All @@ -222,9 +186,6 @@ public function run()
}
}

/**
* {@inheritdoc}
*/
public function stop()
{
$this->running = false;
Expand Down
Loading
0