1 | <?php |
||
9 | class StreamSocketConnectionPool implements ConnectionPoolInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var resource |
||
13 | */ |
||
14 | private $serverSocket; |
||
15 | |||
16 | /** |
||
17 | * @var resource[] |
||
18 | */ |
||
19 | private $clientSockets; |
||
20 | |||
21 | /** |
||
22 | * @var Connection[] |
||
23 | */ |
||
24 | private $connections; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $shutdown; |
||
30 | |||
31 | /** |
||
32 | * Constructor. |
||
33 | * |
||
34 | * @param resource $socket The stream socket to accept connections from |
||
35 | */ |
||
36 | public function __construct($socket) |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function getReadableConnections($timeout) |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function count() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function shutdown() |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function close() |
||
110 | |||
111 | /** |
||
112 | * Uses the stream select function to eliminate all non-readable sockets |
||
113 | * from the read sockets parameter. |
||
114 | * |
||
115 | * @param resource[] $readSockets The sockets to test for readability (output parameter) |
||
116 | * @param int $timeout The stream select call timeout |
||
117 | */ |
||
118 | private function selectConnections(&$readSockets, $timeout) |
||
144 | |||
145 | /** |
||
146 | * Accept incoming connections from the server stream socket. |
||
147 | */ |
||
148 | private function acceptConnection() |
||
163 | |||
164 | /** |
||
165 | * Remove connections. |
||
166 | */ |
||
167 | private function removeClosedConnections() |
||
176 | } |
||
177 |