Skip to content

Documentation for monotonic time source vs wall-clock time #130

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 1 commit into from
Dec 4, 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
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For the code of the current stable 0.4.x release, checkout the
* [ExtLibeventLoop](#extlibeventloop)
* [ExtLibevLoop](#extlibevloop)
* [LoopInterface](#loopinterface)
* [addtimer()](#addtimer)
* [addTimer()](#addtimer)
* [addPeriodicTimer()](#addperiodictimer)
* [cancelTimer()](#canceltimer)
* [isTimerActive()](#istimeractive)
Expand Down Expand Up @@ -184,6 +184,15 @@ 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.

This event loop is known to rely on wall-clock time to schedule future
timers, because a monotonic time source is not available in PHP by default.
While this does not affect many common use cases, this is an important
distinction for programs that rely on a high time precision or on systems
that are subject to discontinuous time adjustments (time jumps).
This means that if you schedule a timer to trigger in 30s and then adjust
your system time forward by 20s, the timer may trigger in 10s.
See also [`addTimer()`](#addtimer) for more details.

#### ExtEventLoop

An `ext-event` based event loop.
Expand Down Expand Up @@ -267,6 +276,17 @@ hello('Tester', $loop);
The execution order of timers scheduled to execute at the same time is
not guaranteed.

This interface suggests that event loop implementations SHOULD use a
monotic time source if available. Given that a monotonic time source is
not available on PHP by default, event loop implementations MAY fall back
to using wall-clock time.
While this does not affect many common use cases, this is an important
distinction for programs that rely on a high time precision or on systems
that are subject to discontinuous time adjustments (time jumps).
This means that if you schedule a timer to trigger in 30s and then adjust
your system time forward by 20s, the timer SHOULD still trigger in 30s.
See also [event loop implementations](#loop-implementations) for more details.

#### addPeriodicTimer()

The `addPeriodicTimer(float $interval, callable $callback): TimerInterface` method can be used to
Expand Down
11 changes: 11 additions & 0 deletions src/LoopInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ public function addTimer($interval, callable $callback);
* The execution order of timers scheduled to execute at the same time is
* not guaranteed.
*
* This interface suggests that event loop implementations SHOULD use a
* monotic time source if available. Given that a monotonic time source is
* not available on PHP by default, event loop implementations MAY fall back
* to using wall-clock time.
* While this does not affect many common use cases, this is an important
* distinction for programs that rely on a high time precision or on systems
* that are subject to discontinuous time adjustments (time jumps).
* This means that if you schedule a timer to trigger in 30s and then adjust
* your system time forward by 20s, the timer SHOULD still trigger in 30s.
* See also [event loop implementations](#loop-implementations) for more details.
*
* @param int|float $interval The number of seconds to wait before execution.
* @param callable $callback The callback to invoke.
*
Expand Down
9 changes: 9 additions & 0 deletions src/StreamSelectLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
* If this extension is missing (or you're running on Windows), signal handling is
* not supported and throws a `BadMethodCallException` instead.
*
* This event loop is known to rely on wall-clock time to schedule future
* timers, because a monotonic time source is not available in PHP by default.
* While this does not affect many common use cases, this is an important
* distinction for programs that rely on a high time precision or on systems
* that are subject to discontinuous time adjustments (time jumps).
* This means that if you schedule a timer to trigger in 30s and then adjust
* your system time forward by 20s, the timer may trigger in 10s.
* See also [`addTimer()`](#addtimer) for more details.
*
* @link http://php.net/manual/en/function.stream-select.php
*/
class StreamSelectLoop implements LoopInterface
Expand Down
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