forked from azjezz/psl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReceiverInterface.php
40 lines (36 loc) · 1.1 KB
/
ReceiverInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Psl\Channel;
/**
* @template T
*
* @extends ChannelInterface<T>
*/
interface ReceiverInterface extends ChannelInterface
{
/**
* Receives a message from the channel.
*
* If the channel is empty, this method waits until there is a message.
*
* If the channel is closed, this method receives a message or throws if there are no more messages.
*
* @throws Exception\ClosedChannelException If the channel is closed, and there's no more messages to receive.
*
* @return T
*/
public function receive(): mixed;
/**
* Receives a message from the channel immediately.
*
* If the channel is empty, this method will throw an exception.
*
* If the channel is closed, this method receives a message or throws if there are no more messages.
*
* @throws Exception\ClosedChannelException If the channel is closed, and there's no more messages to receive.
* @throws Exception\EmptyChannelException If the channel is empty.
*
* @return T
*/
public function tryReceive(): mixed;
}