diff --git a/README.md b/README.md index 27bb0bd3..2c48b410 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,15 @@ 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. +This event loop is known to trigger a readable listener only if +the stream *becomes* readable (edge-triggered) and may not trigger if the +stream has already been readable from the beginning. +This also implies that a stream may not be recognized as readable when data +is still left in PHP's internal stream buffers. +As such, it's recommended to use `stream_set_read_buffer($stream, 0);` +to disable PHP's internal read buffer in this case. +See also [`addReadStream()`](#addreadstream) for more details. + #### ExtLibevLoop An `ext-libev` based event loop. @@ -482,6 +491,14 @@ read event listener for this stream. The execution order of listeners when multiple streams become ready at the same time is not guaranteed. +Some event loop implementations are known to only trigger the listener if +the stream *becomes* readable (edge-triggered) and may not trigger if the +stream has already been readable from the beginning. +This also implies that a stream may not be recognized as readable when data +is still left in PHP's internal stream buffers. +As such, it's recommended to use `stream_set_read_buffer($stream, 0);` +to disable PHP's internal read buffer in this case. + #### addWriteStream() > Advanced! Note that this low-level API is considered advanced usage. diff --git a/src/ExtLibeventLoop.php b/src/ExtLibeventLoop.php index 0d0a1b3e..08896b4f 100644 --- a/src/ExtLibeventLoop.php +++ b/src/ExtLibeventLoop.php @@ -22,6 +22,15 @@ * Accordingly, the [`Factory`](#factory) will not try to use this event loop on * PHP 7. * + * This event loop is known to trigger a readable listener only if + * the stream *becomes* readable (edge-triggered) and may not trigger if the + * stream has already been readable from the beginning. + * This also implies that a stream may not be recognized as readable when data + * is still left in PHP's internal stream buffers. + * As such, it's recommended to use `stream_set_read_buffer($stream, 0);` + * to disable PHP's internal read buffer in this case. + * See also [`addReadStream()`](#addreadstream) for more details. + * * @link https://pecl.php.net/package/libevent */ class ExtLibeventLoop implements LoopInterface diff --git a/src/LoopInterface.php b/src/LoopInterface.php index 57783fab..fa905914 100644 --- a/src/LoopInterface.php +++ b/src/LoopInterface.php @@ -94,6 +94,14 @@ public function addReadStream($stream, callable $listener); * The execution order of listeners when multiple streams become ready at * the same time is not guaranteed. * + * Some event loop implementations are known to only trigger the listener if + * the stream *becomes* readable (edge-triggered) and may not trigger if the + * stream has already been readable from the beginning. + * This also implies that a stream may not be recognized as readable when data + * is still left in PHP's internal stream buffers. + * As such, it's recommended to use `stream_set_read_buffer($stream, 0);` + * to disable PHP's internal read buffer in this case. + * * @param resource $stream The PHP stream resource to check. * @param callable $listener Invoked when the stream is ready. * @see self::removeWriteStream() 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