2020-08-23 16:18:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A pipeline is an asynchronous set of ordered values.
|
|
|
|
*
|
|
|
|
* @template-covariant TValue
|
|
|
|
*/
|
2020-11-10 19:05:47 +01:00
|
|
|
interface Pipeline extends \Traversable
|
2020-08-23 16:18:28 +02:00
|
|
|
{
|
|
|
|
/**
|
2020-11-10 19:05:47 +01:00
|
|
|
* Returns the emitted value if the pipeline has emitted a value or null if the pipeline has completed.
|
|
|
|
* If the pipeline fails, the exception will be thrown from this method.
|
|
|
|
*
|
|
|
|
* This method exists primarily for async consumption using Amp\async(fn() => $pipeline->continue()).
|
2020-08-23 16:18:28 +02:00
|
|
|
*
|
2020-09-25 05:14:58 +02:00
|
|
|
* @return mixed Returns null if the pipeline has completed.
|
2020-08-23 16:18:28 +02:00
|
|
|
*
|
2020-11-10 20:28:43 +01:00
|
|
|
* @psalm-return TValue|null
|
2020-08-23 16:18:28 +02:00
|
|
|
*
|
|
|
|
* @throws \Throwable The exception used to fail the pipeline.
|
|
|
|
*/
|
2020-09-25 05:14:58 +02:00
|
|
|
public function continue(): mixed;
|
2020-08-23 16:18:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disposes of the pipeline, indicating the consumer is no longer interested in the pipeline output.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-09-24 18:52:22 +02:00
|
|
|
public function dispose(): void;
|
2020-08-23 16:18:28 +02:00
|
|
|
}
|