1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-11 16:49:51 +01:00
parallel/lib/Sync/Channel.php

37 lines
1.3 KiB
PHP
Raw Normal View History

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
use Amp\Promise;
/**
2015-12-05 06:50:32 +01:00
* Interface for sending messages between execution contexts.
*/
2018-10-07 16:50:45 +02:00
interface Channel
{
2015-09-03 01:29:48 +02:00
/**
* @return \Amp\Promise<mixed>
2015-08-25 16:37:22 +02:00
*
2017-12-08 04:26:55 +01:00
* @throws \Amp\Parallel\Context\StatusError Thrown if the context has not been started.
* @throws \Amp\Parallel\Sync\SynchronizationError If the context has not been started or the context
2015-12-05 06:50:32 +01:00
* unexpectedly ends.
* @throws \Amp\Parallel\Sync\ChannelException If receiving from the channel fails.
* @throws \Amp\Parallel\Sync\SerializationException If unserializing the data fails.
*/
2016-11-15 00:43:44 +01:00
public function receive(): Promise;
/**
2015-12-05 06:50:32 +01:00
* @param mixed $data
*
* @return \Amp\Promise<int> Resolves with the number of bytes sent on the channel.
2015-12-05 06:50:32 +01:00
*
2017-12-08 04:26:55 +01:00
* @throws \Amp\Parallel\Context\StatusError Thrown if the context has not been started.
* @throws \Amp\Parallel\Sync\SynchronizationError If the context has not been started or the context
2015-12-05 06:50:32 +01:00
* unexpectedly ends.
* @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.
* @throws \Amp\Parallel\Sync\SerializationException If serializing the data fails.
*/
2016-11-15 00:43:44 +01:00
public function send($data): Promise;
}