1
0
mirror of https://github.com/danog/loop.git synced 2024-12-12 09:19:45 +01:00
loop/lib/Interfaces/ResumableLoopInterface.php
2020-07-22 18:18:57 +02:00

43 lines
1.0 KiB
PHP

<?php
/**
* Resumable loop interface.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/MIT MIT
*/
namespace danog\Loop\Interfaces;
use Amp\Promise;
/**
* Resumable loop interface.
*
* @author Daniil Gentili <daniil@daniil.it>
*/
interface ResumableLoopInterface extends LoopInterface
{
/**
* Pause the loop.
*
* @param ?int $time Milliseconds for how long to pause the loop, if null will pause forever (until resume is called from outside of the loop)
*
* @return Promise Resolved when the loop is resumed
*/
public function pause(?int $time = null): Promise;
/**
* Resume the loop.
*
* @return Promise Resolved when the loop is paused again
*/
public function resume(): Promise;
/**
* Defer resuming the loop to next tick.
*
* @return Promise Resolved when the loop is paused again
*/
public function resumeDefer(): Promise;
}