@@ -18,19 +18,25 @@ For the code of the current stable 0.4.x release, checkout the
1818
1919* [ Quickstart example] ( #quickstart-example )
2020* [ Usage] ( #usage )
21- * [ Factory] ( #factory )
22- * [ Loop implementations] ( #loop-implementations )
23- * [ addtimer()] ( #addtimer )
24- * [ addPeriodicTimer()] ( #addperiodictimer )
25- * [ cancelTimer()] ( #canceltimer )
26- * [ isTimerActive()] ( #istimeractive )
27- * [ futureTick()] ( #futuretick )
28- * [ addSignal()] ( #addsignal )
29- * [ removeSignal()] ( #removesignal )
30- * [ addReadStream()] ( #addreadstream )
31- * [ addWriteStream()] ( #addwritestream )
32- * [ removeReadStream()] ( #removereadstream )
33- * [ removeWriteStream()] ( #removewritestream )
21+ * [ Factory] ( #factory )
22+ * [ create()] ( #create )
23+ * [ Loop implementations] ( #loop-implementations )
24+ * [ StreamSelectLoop] ( #streamselectloop )
25+ * [ LibEventLoop] ( #libeventloop )
26+ * [ LibEvLoop] ( #libevloop )
27+ * [ ExtEventLoop] ( #exteventloop )
28+ * [ LoopInterface] ( #loopinterface )
29+ * [ addtimer()] ( #addtimer )
30+ * [ addPeriodicTimer()] ( #addperiodictimer )
31+ * [ cancelTimer()] ( #canceltimer )
32+ * [ isTimerActive()] ( #istimeractive )
33+ * [ futureTick()] ( #futuretick )
34+ * [ addSignal()] ( #addsignal )
35+ * [ removeSignal()] ( #removesignal )
36+ * [ addReadStream()] ( #addreadstream )
37+ * [ addWriteStream()] ( #addwritestream )
38+ * [ removeReadStream()] ( #removereadstream )
39+ * [ removeWriteStream()] ( #removewritestream )
3440* [ Install] ( #install )
3541* [ Tests] ( #tests )
3642* [ License] ( #license )
@@ -106,49 +112,79 @@ $loop->run();
106112 purposes.
1071133 . The loop is run with a single ` $loop->run() ` call at the end of the program.
108114
109- ## Factory
115+ ### Factory
110116
111117The ` Factory ` class exists as a convenient way to pick the best available
112- [ loop implementation] ( #loop-implementations ) .
118+ [ event loop implementation] ( #loop-implementations ) .
113119
114- The ` create(): LoopInterface ` method can be used to create a new loop
120+ #### create()
121+
122+ The ` create(): LoopInterface ` method can be used to create a new event loop
115123instance:
116124
117125``` php
118126$loop = React\EventLoop\Factory::create();
119127```
120128
121- This method always returns an instance implementing ` LoopInterface ` ,
122- the actual loop implementation is an implementation detail.
129+ This method always returns an instance implementing [ ` LoopInterface ` ] ( #loopinterface ) ,
130+ the actual [ event loop implementation] ( #loop-implementations ) is an implementation detail.
123131
124132This method should usually only be called once at the beginning of the program.
125133
126- ## Loop implementations
127-
128- In addition to the interface there are the following implementations provided:
129-
130- * ` StreamSelectLoop ` : This is the only implementation which works out of the
131- box with PHP. It does a simple ` select ` system call. It's not the most
132- performant of loops, but still does the job quite well.
134+ ### Loop implementations
133135
134- * ` LibEventLoop ` : This uses the ` libevent ` pecl extension. ` libevent ` itself
135- supports a number of system-specific backends (epoll, kqueue) .
136+ In addition to the [ ` LoopInterface ` ] ( #loopinterface ) , there are a number of
137+ event loop implementations provided .
136138
137- * ` LibEvLoop ` : This uses the ` libev ` pecl extension
138- ([ github] ( https://github.com/m4rw3r/php-libev ) ). It supports the same
139- backends as libevent.
140-
141- * ` ExtEventLoop ` : This uses the ` event ` pecl extension. It supports the same
142- backends as libevent.
143-
144- All of the loops support these features:
139+ All of the event loops support these features:
145140
146141* File descriptor polling
147142* One-off timers
148143* Periodic timers
149144* Deferred execution on future loop tick
150145
151- ### addTimer()
146+ For most consumers of this package, the underlying event loop implementation is
147+ an implementation detail.
148+ You should use the [ ` Factory ` ] ( #factory ) to automatically create a new instance.
149+
150+ Advanced! If you explicitly need a certain event loop implementation, you can
151+ manually instantiate one of the following classes.
152+ Note that you may have to install the required PHP extensions for the respective
153+ event loop implementation first or this may result in a fatal error.
154+
155+ #### StreamSelectLoop
156+
157+ A ` stream_select() ` based event loop.
158+
159+ This uses the [ ` stream_select() ` ] ( http://php.net/manual/en/function.stream-select.php )
160+ function and is the only implementation which works out of the box with PHP.
161+ It does a simple ` select ` system call.
162+ It's not the most performant of loops, but still does the job quite well.
163+
164+ #### LibEventLoop
165+
166+ An ` ext-libevent ` based event loop.
167+
168+ This uses the [ ` libevent ` PECL extension] ( https://pecl.php.net/package/libevent ) .
169+ ` libevent ` itself supports a number of system-specific backends (epoll, kqueue).
170+
171+ #### LibEvLoop
172+
173+ An ` ext-libev ` based event loop.
174+
175+ This uses an [ unofficial ` libev ` extension] ( https://github.com/m4rw3r/php-libev ) .
176+ It supports the same backends as libevent.
177+
178+ #### ExtEventLoop
179+
180+ An ` ext-event ` based event loop.
181+
182+ This uses the [ ` event ` PECL extension] ( https://pecl.php.net/package/event ) .
183+ It supports the same backends as libevent.
184+
185+ ### LoopInterface
186+
187+ #### addTimer()
152188
153189The ` addTimer(float $interval, callable $callback): TimerInterface ` method can be used to
154190enqueue a callback to be invoked once after the given interval.
@@ -195,7 +231,7 @@ hello('Tester', $loop);
195231The execution order of timers scheduled to execute at the same time is
196232not guaranteed.
197233
198- ### addPeriodicTimer()
234+ #### addPeriodicTimer()
199235
200236The ` addPeriodicTimer(float $interval, callable $callback): TimerInterface ` method can be used to
201237enqueue a callback to be invoked repeatedly after the given interval.
@@ -249,7 +285,7 @@ hello('Tester', $loop);
249285The execution order of timers scheduled to execute at the same time is
250286not guaranteed.
251287
252- ### cancelTimer()
288+ #### cancelTimer()
253289
254290The ` cancelTimer(TimerInterface $timer): void ` method can be used to
255291cancel a pending timer.
@@ -264,7 +300,7 @@ Calling this method on a timer instance that has not been added to this
264300loop instance or on a timer that is not "active" (or has already been
265301cancelled) has no effect.
266302
267- ### isTimerActive()
303+ #### isTimerActive()
268304
269305The ` isTimerActive(TimerInterface $timer): bool ` method can be used to
270306check if a given timer is active.
@@ -274,7 +310,7 @@ via [`addTimer()`](#addtimer) or [`addPeriodicTimer()`](#addperiodictimer)
274310and has not been cancelled via [ ` cancelTimer() ` ] ( #canceltimer ) and is not
275311a non-periodic timer that has already been triggered after its interval.
276312
277- ### futureTick()
313+ #### futureTick()
278314
279315The ` futureTick(callable $listener): void ` method can be used to
280316schedule a callback to be invoked on a future tick of the event loop.
@@ -322,7 +358,7 @@ echo 'a';
322358
323359See also [ example #3 ] ( examples ) .
324360
325- ### addSignal()
361+ #### addSignal()
326362
327363The ` addSignal(int $signal, callable $listener): void ` method can be used to
328364register a listener to be notified when a signal has been caught by this process.
@@ -356,7 +392,7 @@ missing.
356392** Note: A listener can only be added once to the same signal, any
357393attempts to add it more then once will be ignored.**
358394
359- ### removeSignal()
395+ #### removeSignal()
360396
361397The ` removeSignal(int $signal, callable $listener): void ` method can be used to
362398remove a previously added signal listener.
@@ -367,7 +403,7 @@ $loop->removeSignal(SIGINT, $listener);
367403
368404Any attempts to remove listeners that aren't registered will be ignored.
369405
370- ### addReadStream()
406+ #### addReadStream()
371407
372408> Advanced! Note that this low-level API is considered advanced usage.
373409 Most use cases should probably use the higher-level
@@ -410,7 +446,7 @@ read event listener for this stream.
410446The execution order of listeners when multiple streams become ready at
411447the same time is not guaranteed.
412448
413- ### addWriteStream()
449+ #### addWriteStream()
414450
415451> Advanced! Note that this low-level API is considered advanced usage.
416452 Most use cases should probably use the higher-level
@@ -453,15 +489,15 @@ write event listener for this stream.
453489The execution order of listeners when multiple streams become ready at
454490the same time is not guaranteed.
455491
456- ### removeReadStream()
492+ #### removeReadStream()
457493
458494The ` removeReadStream(resource $stream): void ` method can be used to
459495remove the read event listener for the given stream.
460496
461497Removing a stream from the loop that has already been removed or trying
462498to remove a stream that was never added or is invalid has no effect.
463499
464- ### removeWriteStream()
500+ #### removeWriteStream()
465501
466502The ` removeWriteStream(resource $stream): void ` method can be used to
467503remove the write event listener for the given stream.
@@ -480,6 +516,14 @@ This will install the latest supported version:
480516$ composer require react/event-loop
481517```
482518
519+ This project aims to run on any platform and thus does not require any PHP
520+ extensions and supports running on legacy PHP 5.4 through current PHP 7+ and
521+ HHVM.
522+ It's * highly recommended to use PHP 7+* for this project.
523+
524+ Installing any of the event loop extensions is suggested, but entirely optional.
525+ See also [ event loop implementations] ( #loop-implementations ) for more details.
526+
483527## Tests
484528
485529To run the test suite, you first need to clone this repo and then install all
0 commit comments