2015-08-03 06:45:31 +02:00
|
|
|
<?php
|
2016-08-18 18:04:48 +02:00
|
|
|
|
|
|
|
namespace Amp\Concurrent\Sync;
|
|
|
|
|
|
|
|
use Interop\Async\Awaitable;
|
2015-08-03 06:45:31 +02:00
|
|
|
|
|
|
|
/**
|
2015-12-05 06:50:32 +01:00
|
|
|
* Interface for sending messages between execution contexts.
|
2015-08-03 06:45:31 +02:00
|
|
|
*/
|
2016-08-18 18:04:48 +02:00
|
|
|
interface Channel {
|
2015-09-03 01:29:48 +02:00
|
|
|
/**
|
2016-08-18 18:04:48 +02:00
|
|
|
* @return \Interop\Async\Awaitable<mixed>
|
2015-08-25 16:37:22 +02:00
|
|
|
*
|
2016-08-18 18:04:48 +02:00
|
|
|
* @throws \Amp\Concurrent\StatusError Thrown if the context has not been started.
|
|
|
|
* @throws \Amp\Concurrent\SynchronizationError If the context has not been started or the context
|
2015-12-05 06:50:32 +01:00
|
|
|
* unexpectedly ends.
|
2016-08-18 18:04:48 +02:00
|
|
|
* @throws \Amp\Concurrent\ChannelException If receiving from the channel fails.
|
|
|
|
* @throws \Amp\Concurrent\SerializationException If unserializing the data fails.
|
2015-08-03 06:45:31 +02:00
|
|
|
*/
|
2016-08-18 18:04:48 +02:00
|
|
|
public function receive(): Awaitable;
|
2015-08-03 06:45:31 +02:00
|
|
|
|
|
|
|
/**
|
2015-12-05 06:50:32 +01:00
|
|
|
* @param mixed $data
|
|
|
|
*
|
2016-08-18 18:04:48 +02:00
|
|
|
* @return \Interop\Async\Awaitable<int> Resolves with the number of bytes sent on the channel.
|
2015-12-05 06:50:32 +01:00
|
|
|
*
|
2016-08-18 18:04:48 +02:00
|
|
|
* @throws \Amp\Concurrent\StatusError Thrown if the context has not been started.
|
|
|
|
* @throws \Amp\Concurrent\SynchronizationError If the context has not been started or the context
|
2015-12-05 06:50:32 +01:00
|
|
|
* unexpectedly ends.
|
2016-08-18 18:04:48 +02:00
|
|
|
* @throws \Amp\Concurrent\ChannelException If sending on the channel fails.
|
|
|
|
* @throws \Error If an ExitStatus object is given.
|
|
|
|
* @throws \Amp\Concurrent\SerializationException If serializing the data fails.
|
2015-08-03 06:45:31 +02:00
|
|
|
*/
|
2016-08-18 18:04:48 +02:00
|
|
|
public function send($data): Awaitable;
|
2015-08-03 06:45:31 +02:00
|
|
|
}
|