mirror of
https://github.com/danog/loop.git
synced 2024-11-26 20:04:44 +01:00
46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Signal 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;
|
|
|
|
use Amp\Promise;
|
|
|
|
/**
|
|
* Signal loop interface.
|
|
*
|
|
* @author Daniil Gentili <daniil@daniil.it>
|
|
*/
|
|
interface SignalLoopInterface extends LoopInterface
|
|
{
|
|
/**
|
|
* Send a signal to the the loop.
|
|
*
|
|
* @param \Throwable|mixed $data Signal to send
|
|
*
|
|
* @return void
|
|
*/
|
|
public function signal($data): void;
|
|
/**
|
|
* Resolve the promise or return|throw the signal.
|
|
*
|
|
* @param Promise|\Generator $promise The original promise or generator
|
|
*
|
|
* @return Promise
|
|
*
|
|
* @template T
|
|
*
|
|
* @psalm-param Promise<T>|\Generator<mixed,Promise|array<array-key,
|
|
* Promise>,mixed,Promise<T>|T> $promise The original promise or generator
|
|
*
|
|
* @psalm-return Promise<T|mixed>
|
|
*/
|
|
public function waitSignal($promise): Promise;
|
|
}
|