2016-12-30 02:16:04 +01:00
|
|
|
<?php
|
2016-08-18 18:04:48 +02:00
|
|
|
|
2016-08-23 23:47:40 +02:00
|
|
|
namespace Amp\Parallel\Sync;
|
2016-08-18 18:04:48 +02:00
|
|
|
|
2017-03-16 23:03:59 +01:00
|
|
|
use Amp\Promise;
|
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
|
|
|
/**
|
2017-03-16 23:03:59 +01:00
|
|
|
* @return \Amp\Promise<mixed>
|
2015-08-25 16:37:22 +02:00
|
|
|
*
|
2016-08-23 23:47:40 +02:00
|
|
|
* @throws \Amp\Parallel\StatusError Thrown if the context has not been started.
|
|
|
|
* @throws \Amp\Parallel\SynchronizationError If the context has not been started or the context
|
2015-12-05 06:50:32 +01:00
|
|
|
* unexpectedly ends.
|
2017-11-10 18:32:15 +01:00
|
|
|
* @throws \Amp\Parallel\Sync\ChannelException If receiving from the channel fails.
|
|
|
|
* @throws \Amp\Parallel\Sync\SerializationException If unserializing the data fails.
|
2015-08-03 06:45:31 +02:00
|
|
|
*/
|
2016-11-15 00:43:44 +01:00
|
|
|
public function receive(): Promise;
|
2015-08-03 06:45:31 +02:00
|
|
|
|
|
|
|
/**
|
2015-12-05 06:50:32 +01:00
|
|
|
* @param mixed $data
|
|
|
|
*
|
2017-03-16 23:03:59 +01:00
|
|
|
* @return \Amp\Promise<int> Resolves with the number of bytes sent on the channel.
|
2015-12-05 06:50:32 +01:00
|
|
|
*
|
2016-08-23 23:47:40 +02:00
|
|
|
* @throws \Amp\Parallel\StatusError Thrown if the context has not been started.
|
|
|
|
* @throws \Amp\Parallel\SynchronizationError If the context has not been started or the context
|
2015-12-05 06:50:32 +01:00
|
|
|
* unexpectedly ends.
|
2017-11-10 18:32:15 +01:00
|
|
|
* @throws \Amp\Parallel\Sync\ChannelException If sending on the channel fails.
|
2017-01-17 06:24:59 +01:00
|
|
|
* @throws \Error If an ExitResult object is given.
|
2017-11-10 18:32:15 +01:00
|
|
|
* @throws \Amp\Parallel\Sync\SerializationException If serializing the data fails.
|
2015-08-03 06:45:31 +02:00
|
|
|
*/
|
2016-11-15 00:43:44 +01:00
|
|
|
public function send($data): Promise;
|
2015-08-03 06:45:31 +02:00
|
|
|
}
|