1 | <?php |
||
10 | trait DaemonTrait |
||
11 | { |
||
12 | /** |
||
13 | * @var bool |
||
14 | */ |
||
15 | private $isShutdown = false; |
||
16 | |||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | private $requestCount; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | private $requestLimit; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $memoryLimit; |
||
31 | |||
32 | /** |
||
33 | * Flags the daemon for shutting down. |
||
34 | */ |
||
35 | public function flagShutdown() |
||
39 | |||
40 | /** |
||
41 | * Loads to configuration from the daemon options and installs signal |
||
42 | * handlers. |
||
43 | * |
||
44 | * @param DaemonOptions $daemonOptions |
||
45 | */ |
||
46 | private function setupDaemon(DaemonOptions $daemonOptions) |
||
60 | |||
61 | /** |
||
62 | * Increments the request count. |
||
63 | * |
||
64 | * @param int $number The number of requests to increment the count by |
||
65 | */ |
||
66 | private function incrementRequestCount($number) |
||
70 | |||
71 | /** |
||
72 | * Installs a handler which throws a ShutdownException upon receiving a |
||
73 | * SIGINT or a SIGALRM. |
||
74 | * |
||
75 | * @throws ShutdownException On receiving a SIGINT or SIGALRM |
||
76 | */ |
||
77 | private function installSignalHandlers() |
||
89 | |||
90 | /** |
||
91 | * Checks the current PHP process against the limits specified in a daemon |
||
92 | * options object. This function will also throw an exception if the daemon |
||
93 | * has been flagged for shutdown. |
||
94 | * |
||
95 | * @throws ShutdownException When limits in the daemon options are exceeded |
||
96 | */ |
||
97 | private function checkDaemonLimits() |
||
119 | } |
||
120 |