forked from reactphp/async
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiberMap.php
More file actions
38 lines (30 loc) · 842 Bytes
/
FiberMap.php
File metadata and controls
38 lines (30 loc) · 842 Bytes
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
<?php
namespace React\Async;
use React\Promise\PromiseInterface;
/**
* @internal
*/
final class FiberMap
{
private static array $map = [];
public static function register(\Fiber $fiber): void
{
self::$map[\spl_object_id($fiber)] = [];
}
public static function setPromise(\Fiber $fiber, PromiseInterface $promise): void
{
self::$map[\spl_object_id($fiber)] = $promise;
}
public static function unsetPromise(\Fiber $fiber, PromiseInterface $promise): void
{
unset(self::$map[\spl_object_id($fiber)]);
}
public static function getPromise(\Fiber $fiber): ?PromiseInterface
{
return self::$map[\spl_object_id($fiber)] ?? null;
}
public static function unregister(\Fiber $fiber): void
{
unset(self::$map[\spl_object_id($fiber)]);
}
}