PHP Класс malkusch\lock\util\Loop

Автор: Markus Malkusch ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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

end() публичный Метод

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

execute() публичный Метод

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.
Результат mixed The return value of the executed block.