-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathContextChannel.php
More file actions
56 lines (47 loc) · 1.07 KB
/
ContextChannel.php
File metadata and controls
56 lines (47 loc) · 1.07 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php declare(strict_types=1);
namespace Amp\Parallel\Context\Internal;
use Amp\Cancellation;
use Amp\ForbidCloning;
use Amp\ForbidSerialization;
use Amp\Sync\Channel;
/**
* @template-covariant TReceive
* @template TSend
* @implements Channel<TReceive, TSend>
*
* @internal
*/
final class ContextChannel implements Channel
{
use ForbidCloning;
use ForbidSerialization;
public function __construct(
private readonly Channel $channel,
) {
}
#[\Override]
public function send(mixed $data): void
{
$this->channel->send(new ContextMessage($data));
}
#[\Override]
public function receive(?Cancellation $cancellation = null): mixed
{
return $this->channel->receive($cancellation);
}
#[\Override]
public function close(): void
{
$this->channel->close();
}
#[\Override]
public function isClosed(): bool
{
return $this->channel->isClosed();
}
#[\Override]
public function onClose(\Closure $onClose): void
{
$this->channel->onClose($onClose);
}
}