An implementation of timers.
More...
|
|
| $args |
| | Additional arguments to call the callback function with.
|
| |
|
| $callback |
| | Function or method to call when the timer expires.
|
| |
|
| $delay |
| | Delay after which the timer will expire.
|
| |
|
| $handle |
| | A file descriptor which is used to implement timers.
|
| |
|
| $repeat |
| | Number of times the timer will be reset.
|
| |
|
| $resource |
| | Internal resource used to implement timers.
|
| |
|
|
static | $binary = null |
| | Path to the PHP binary to use to launch timers.
|
| |
|
static | $windowsStrategy = 0 |
| | Activate a special strategy for Windows.
|
| |
An implementation of timers.
Definition at line 27 of file Timer.php.
Creates a new timer, set off to call the given callback (optionally, repeatedly) when the associated delay passed.
- Parameters
-
| Erebot::CallableInterface | $callback | The callback to call when the timer expires. See http://php.net/manual/en/language.pseudo-types.php for acceptable callback values. |
| number | $delay | The number of seconds to wait for before calling the callback. This may be a float/double or an int, but the implementation may choose to round it up to the nearest integer if sub-second precision is impossible to get (eg. on Windows). |
| bool | int | $repeat | Either a boolean indicating whether the callback should be called repeatedly every $delay seconds or just once, or an integer specifying the exact number of times the callback will be called. |
| array | $args | (optional) Additional arguments to pass to the callback when it is called. |
Definition at line 79 of file Timer.php.
| Erebot\Timer::activate |
( |
| ) |
|
Calls the callback.
- Warning
- This method is called automatically and should not be called manually. Calling it manually may lead to unexpected results.
Implements Erebot\TimerInterface.
Definition at line 258 of file Timer.php.
| Erebot\Timer::cleanup |
( |
| ) |
|
|
protected |
Performs cleanup duties so that no traces of this timer having ever been used remain.
Definition at line 123 of file Timer.php.
| Erebot\Timer::getArgs |
( |
| ) |
|
Returns an array of additional arguments to pass to the callback.
- Return values
-
| array | Arguments that will be passed to the callback. |
- Note
- The first argument passed to the callback is ALWAYS the timer event that timed out, but the timer IS NOT considered as a part of the arguments for the purpose of this method and therefore will be missing from the array it returns.
Implements Erebot\TimerInterface.
Definition at line 152 of file Timer.php.
| Erebot\Timer::getCallback |
( |
| ) |
|
Returns a reference to the callback associated with this timer.
- Return values
-
| callback | The callback for this timer. |
Implements Erebot\TimerInterface.
Definition at line 142 of file Timer.php.
| Erebot\Timer::getDelay |
( |
| ) |
|
Returns the delay after which the callback will be called. This is the original value given to the timer during construction, and it is not updated live as time passes by.
- Return values
-
| number | The original delay for this timer, as decided at construction time. |
Implements Erebot\TimerInterface.
Definition at line 157 of file Timer.php.
| Erebot\Timer::getRepetition |
( |
| ) |
|
Returns the number of timer this timer will be restarted.
- Return values
-
| int | Returns the repetition state of the timer. |
Implements Erebot\TimerInterface.
Definition at line 162 of file Timer.php.
| Erebot\Timer::getStream |
( |
| ) |
|
Returns the underlying stream used by the implementation to create timers.
- Return values
-
| stream | The underlying PHP stream. |
Implements Erebot\TimerInterface.
Definition at line 184 of file Timer.php.
(Re)starts the timer.
- Postcondition
- The timer is started. The repetition counter is decremented as necessary.
- Warning
- It is the responsability of whoever uses the timer to restart it when needed.
Implements Erebot\TimerInterface.
Definition at line 189 of file Timer.php.
| Erebot\Timer::setArgs |
( |
array |
$args | ) |
|
Sets the arguments for this timer.
Whenever this timer fires, its callback will be called with these arguments.
- Parameters
-
| array | $args | An array containing the parameters to pass to this timer's callback whenever it fires. The parameters will be passed in the same order they appear in this array. |
Implements Erebot\TimerInterface.
Definition at line 147 of file Timer.php.
| Erebot\Timer::setRepetition |
( |
|
$repeat | ) |
|
Changes the number of times this timer can go off.
- Parameters
-
| bool | int | $repeat | Can be either:
- An integer indicating the number of times the timer will be triggered (with any negative value being treated as positive infinity).
- A boolean which indicates that the timer should call the callback repeatedly (true, same as -1) or just once (false, same as 1).
|
Implements Erebot\TimerInterface.
Definition at line 167 of file Timer.php.
The documentation for this class was generated from the following file: