1
0
mirror of https://github.com/danog/loop.git synced 2024-12-04 10:18:02 +01:00
loop/lib/Interfaces/ResumableLoopInterface.php

43 lines
1.0 KiB
PHP
Raw Normal View History

2020-07-21 18:06:19 +02:00
<?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
*/
2020-07-21 21:45:22 +02:00
namespace danog\Loop\Interfaces;
2020-07-21 18:06:19 +02:00
use Amp\Promise;
/**
* Resumable loop interface.
*
* @author Daniil Gentili <daniil@daniil.it>
*/
interface ResumableLoopInterface extends LoopInterface
{
/**
* Pause the loop.
*
2020-07-22 18:18:57 +02:00
* @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)
2020-07-21 18:06:19 +02:00
*
* @return Promise Resolved when the loop is resumed
*/
2020-07-22 18:18:57 +02:00
public function pause(?int $time = null): Promise;
2020-07-21 18:06:19 +02:00
/**
* Resume the loop.
*
* @return Promise Resolved when the loop is paused again
*/
public function resume(): Promise;
2020-07-21 19:41:17 +02:00
/**
* Defer resuming the loop to next tick.
*
* @return Promise Resolved when the loop is paused again
*/
public function resumeDefer(): Promise;
2020-07-21 18:06:19 +02:00
}