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

Skip to content

Documentation for event loop implementations #127

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 3 commits into from
Dec 4, 2017
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
Prev Previous commit
Documentation for common event loop use cases
  • Loading branch information
clue committed Dec 4, 2017
commit ffe26e93ff97a44762a5f7a8ca9f8957dced395f
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,31 @@ A `stream_select()` based event loop.

This uses the [`stream_select()`](http://php.net/manual/en/function.stream-select.php)
function and is the only implementation which works out of the box with PHP.
It does a simple `select` system call.
It's not the most performant of loops, but still does the job quite well.

This event loop works out of the box on PHP 5.4 through PHP 7+ and HHVM.
This means that no installation is required and this library works on all
platforms and supported PHP versions.
Accordingly, the [`Factory`](#factory) will use this event loop by default if
you do not install any of the event loop extensions listed below.

Under the hood, it does a simple `select` system call.
This system call is limited to the maximum file descriptor number of
`FD_SETSIZE` (platform dependent, commonly 1024) and scales with `O(m)`
(`m` being the maximum file descriptor number passed).
This means that you may run into issues when handling thousands of streams
concurrently and you may want to look into using one of the alternative
event loop implementations listed below in this case.
If your use case is among the many common use cases that involve handling only
dozens or a few hundred streams at once, then this event loop implementation
performs really well.

If you want to use signal handling (see also [`addSignal()`](#addsignal) below),
this event loop implementation requires `ext-pcntl`.
This extension is only available for Unix-like platforms and does not support
Windows.
It is commonly installed as part of many PHP distributions.
If this extension is missing (or you're running on Windows), signal handling is
not supported and throws a `BadMethodCallException` instead.

#### LibEventLoop

Expand All @@ -168,20 +191,33 @@ An `ext-libevent` based event loop.
This uses the [`libevent` PECL extension](https://pecl.php.net/package/libevent).
`libevent` itself supports a number of system-specific backends (epoll, kqueue).

This event loop does only work with PHP 5.
An [unofficial update](https://github.com/php/pecl-event-libevent/pull/2) for
PHP 7 does exist, but it is known to cause regular crashes due to `SEGFAULT`s.
To reiterate: Using this event loop on PHP 7 is not recommended.
Accordingly, the [`Factory`](#factory) will not try to use this event loop on
PHP 7.

#### LibEvLoop

An `ext-libev` based event loop.

This uses an [unofficial `libev` extension](https://github.com/m4rw3r/php-libev).
It supports the same backends as libevent.

This loop does only work with PHP 5.
An update for PHP 7 is [unlikely](https://github.com/m4rw3r/php-libev/issues/8)
to happen any time soon.

#### ExtEventLoop

An `ext-event` based event loop.

This uses the [`event` PECL extension](https://pecl.php.net/package/event).
It supports the same backends as libevent.

This loop is known to work with PHP 5.4 through PHP 7+.

### LoopInterface

#### addTimer()
Expand Down
2 changes: 2 additions & 0 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* This uses the [`event` PECL extension](https://pecl.php.net/package/event).
* It supports the same backends as libevent.
*
* This loop is known to work with PHP 5.4 through PHP 7+.
*
* @link https://pecl.php.net/package/event
*/
class ExtEventLoop implements LoopInterface
Expand Down
4 changes: 4 additions & 0 deletions src/LibEvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* This uses an [unofficial `libev` extension](https://github.com/m4rw3r/php-libev).
* It supports the same backends as libevent.
*
* This loop does only work with PHP 5.
* An update for PHP 7 is [unlikely](https://github.com/m4rw3r/php-libev/issues/8)
* to happen any time soon.
*
* @see https://github.com/m4rw3r/php-libev
* @see https://gist.github.com/1688204
*/
Expand Down
7 changes: 7 additions & 0 deletions src/LibEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
* This uses the [`libevent` PECL extension](https://pecl.php.net/package/libevent).
* `libevent` itself supports a numb 8000 er of system-specific backends (epoll, kqueue).
*
* This event loop does only work with PHP 5.
* An [unofficial update](https://github.com/php/pecl-event-libevent/pull/2) for
* PHP 7 does exist, but it is known to cause regular crashes due to `SEGFAULT`s.
* To reiterate: Using this event loop on PHP 7 is not recommended.
* Accordingly, the [`Factory`](#factory) will not try to use this event loop on
* PHP 7.
*
* @link https://pecl.php.net/package/libevent
*/
class LibEventLoop implements LoopInterface
Expand Down
27 changes: 25 additions & 2 deletions src/StreamSelectLoop.php
69AA
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,31 @@
*
* This uses the [`stream_select()`](http://php.net/manual/en/function.stream-select.php)
* function and is the only implementation which works out of the box with PHP.
* It does a simple `select` system call.
* It's not the most performant of loops, but still does the job quite well.
*
* This event loop works out of the box on PHP 5.4 through PHP 7+ and HHVM.
* This means that no installation is required and this library works on all
* platforms and supported PHP versions.
* Accordingly, the [`Factory`](#factory) will use this event loop by default if
* you do not install any of the event loop extensions listed below.
*
* Under the hood, it does a simple `select` system call.
* This system call is limited to the maximum file descriptor number of
* `FD_SETSIZE` (platform dependent, commonly 1024) and scales with `O(m)`
* (`m` being the maximum file descriptor number passed).
* This means that you may run into issues when handling thousands of streams
* concurrently and you may want to look into using one of the alternative
* event loop implementations listed below in this case.
* If your use case is among the many common use cases that involve handling only
* dozens or a few hundred streams at once, then this event loop implementation
* performs really well.
*
* If you want to use signal handling (see also [`addSignal()`](#addsignal) below),
* this event loop implementation requires `ext-pcntl`.
* This extension is only available for Unix-like platforms and does not support
* Windows.
* It is commonly installed as part of many PHP distributions.
* If this extension is missing (or you're running on Windows), signal handling is
* not supported and throws a `BadMethodCallException` instead.
*
* @link http://php.net/manual/en/function.stream-select.php
*/
Expand Down
0