2016-12-29 19:16:04 -06:00
|
|
|
<?php
|
2016-08-18 11:04:48 -05:00
|
|
|
|
2016-08-23 16:47:40 -05:00
|
|
|
namespace Amp\Parallel\Sync;
|
2016-08-18 11:04:48 -05:00
|
|
|
|
2016-11-14 17:43:44 -06:00
|
|
|
use Interop\Async\Promise;
|
2015-08-02 23:45:31 -05:00
|
|
|
|
|
|
|
/**
|
2015-12-04 23:50:32 -06:00
|
|
|
* Interface for sending messages between execution contexts.
|
2015-08-02 23:45:31 -05:00
|
|
|
*/
|
2016-08-18 11:04:48 -05:00
|
|
|
interface Channel {
|
2015-09-02 18:29:48 -05:00
|
|
|
/**
|
2016-11-14 17:43:44 -06:00
|
|
|
* @return \Interop\Async\Promise<mixed>
|
2015-08-25 09:37:22 -05:00
|
|
|
*
|
2016-08-23 16:47:40 -05: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-04 23:50:32 -06:00
|
|
|
* unexpectedly ends.
|
2016-08-23 16:47:40 -05:00
|
|
|
* @throws \Amp\Parallel\ChannelException If receiving from the channel fails.
|
|
|
|
* @throws \Amp\Parallel\SerializationException If unserializing the data fails.
|
2015-08-02 23:45:31 -05:00
|
|
|
*/
|
2016-11-14 17:43:44 -06:00
|
|
|
public function receive(): Promise;
|
2015-08-02 23:45:31 -05:00
|
|
|
|
|
|
|
/**
|
2015-12-04 23:50:32 -06:00
|
|
|
* @param mixed $data
|
|
|
|
*
|
2016-11-14 17:43:44 -06:00
|
|
|
* @return \Interop\Async\Promise<int> Resolves with the number of bytes sent on the channel.
|
2015-12-04 23:50:32 -06:00
|
|
|
*
|
2016-08-23 16:47:40 -05: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-04 23:50:32 -06:00
|
|
|
* unexpectedly ends.
|
2016-08-23 16:47:40 -05:00
|
|
|
* @throws \Amp\Parallel\ChannelException If sending on the channel fails.
|
2016-08-18 11:04:48 -05:00
|
|
|
* @throws \Error If an ExitStatus object is given.
|
2016-08-23 16:47:40 -05:00
|
|
|
* @throws \Amp\Parallel\SerializationException If serializing the data fails.
|
2015-08-02 23:45:31 -05:00
|
|
|
*/
|
2016-11-14 17:43:44 -06:00
|
|
|
public function send($data): Promise;
|
2015-08-02 23:45:31 -05:00
|
|
|
}
|