1 | <?php |
||
21 | final class UserlandDaemon implements DaemonInterface |
||
22 | { |
||
23 | use DaemonTrait; |
||
24 | |||
25 | /** |
||
26 | * @var KernelInterface |
||
27 | */ |
||
28 | private $kernel; |
||
29 | |||
30 | /** |
||
31 | * @var DaemonOptions |
||
32 | */ |
||
33 | private $daemonOptions; |
||
34 | |||
35 | /** |
||
36 | * @var ConnectionPoolInterface |
||
37 | */ |
||
38 | private $connectionPool; |
||
39 | |||
40 | /** |
||
41 | * @var ConnectionHandlerFactoryInterface |
||
42 | */ |
||
43 | private $connectionHandlerFactory; |
||
44 | |||
45 | /** |
||
46 | * @var ConnectionHandler[] |
||
47 | */ |
||
48 | private $connectionHandlers; |
||
49 | |||
50 | /** |
||
51 | * Constructor. |
||
52 | * |
||
53 | * @param KernelInterface $kernel The kernel for the daemon to use |
||
54 | * @param DaemonOptions $daemonOptions The daemon configuration |
||
55 | * @param ConnectionPoolInterface $connectionPool The connection pool to accept connections from |
||
56 | * @param ConnectionHandlerFactoryInterface $connectionHandlerFactory A factory class for producing connection handlers |
||
57 | */ |
||
58 | public function __construct(KernelInterface $kernel, DaemonOptions $daemonOptions, ConnectionPoolInterface $connectionPool, ConnectionHandlerFactoryInterface $connectionHandlerFactory) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function run(): void |
||
94 | |||
95 | /** |
||
96 | * Wait for connections in the pool to become readable. Create connection |
||
97 | * handlers for new connections and trigger the ready method when there is |
||
98 | * data for the handlers to receive. Clean up closed connections. |
||
99 | * |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | private function processConnectionPool(): void |
||
123 | |||
124 | /** |
||
125 | * Gracefully shutdown the daemon. |
||
126 | * |
||
127 | * @throws \Exception |
||
128 | */ |
||
129 | private function shutdown(): void |
||
143 | } |
||
144 |