Add continue constant to genericloop

This commit is contained in:
Daniil Gentili 2019-06-02 13:45:12 +02:00
parent e6375a4701
commit 33041140e2
3 changed files with 11 additions and 3 deletions

View File

@ -19,6 +19,7 @@
* split acks * split acks
* TL callabck * TL callabck
* channel state * channel state
* logger
Things to expect in the next releases: Things to expect in the next releases:
Document async apis Document async apis
optional max_id and min_id optional max_id and min_id

View File

@ -29,6 +29,7 @@ class GenericLoop extends ResumableSignalLoop
{ {
const STOP = -1; const STOP = -1;
const PAUSE = null; const PAUSE = null;
const CONTINUE = 0;
protected $callback; protected $callback;
protected $name; protected $name;
@ -36,9 +37,15 @@ class GenericLoop extends ResumableSignalLoop
/** /**
* Constructor * Constructor
* *
* The callback will be bound to the GenericLoop instance: this means that you will be able to use `$this` as if the callback were actually the `loop` function (you can access the API property, use the pause/waitSignal methods & so on).
* The return value of the callable can be:
* A number - the loop will be paused for the specified number of seconds
* GenericLoop::STOP - The loop will stop
* GenericLoop::PAUSE - The loop will pause forever (or until the `resume` method is called on the loop object from outside the loop)
* GenericLoop::CONTINUE - Return this if you want to rerun the loop without waiting
*
* @param \danog\MadelineProto\API $API Instance of MadelineProto * @param \danog\MadelineProto\API $API Instance of MadelineProto
* @param callback $callback Callback to run periodically * @param callback $callback Callback to run
* @param int $timeout Timeout
* @param string $name Fetcher name * @param string $name Fetcher name
*/ */
public function __construct($API, $callback, $name) public function __construct($API, $callback, $name)

View File

@ -35,7 +35,7 @@ abstract class Loop implements LoopInterface
private $count = 0; private $count = 0;
protected $API; public $API;
public function __construct($API) public function __construct($API)
{ {
$this->API = $API; $this->API = $API;