PHP Class malkusch\lock\util\Loop

Author: Markus Malkusch ([email protected])
Datei anzeigen Open project: malkusch/lock Class Usage Examples

Public Methods

Method Description
__construct ( integer $timeout = 3 ) Sets the timeout.
end ( ) Notifies that this was the last iteration.
execute ( callable $code ) : mixed Repeats executing a code until it was succesful.

Method Details

__construct() public method

The default is 3 seconds.
public __construct ( integer $timeout = 3 )
$timeout integer The timeout in seconds.

end() public method

Notifies that this was the last iteration.
public end ( )

execute() public method

The code has to be designed in a way that it can be repeated without any side effects. When execution was successful it should notify that event by calling {@link Loop::end()}. I.e. the only side effects of the code may happen after a successful execution. If the code throws an exception it will stop repeating the execution.
public execute ( callable $code ) : mixed
$code callable The executed code block.
return mixed The return value of the executed block.