Skip to content

Commit 7da057a

Browse files
committed
Ironing out @todo
1 parent a02d47b commit 7da057a

File tree

2 files changed

+122
-46
lines changed

2 files changed

+122
-46
lines changed

PHPDaemon/Core/Daemon.php

+121-45
Original file line numberDiff line numberDiff line change
@@ -21,57 +21,73 @@ class Daemon {
2121
use \PHPDaemon\Traits\StaticObjectWatchdog;
2222

2323
/**
24-
* @TODO DESCR
24+
* Support of runkit sandbox functionality
25+
* @var integer
2526
*/
2627
const SUPPORT_RUNKIT_SANDBOX = 0;
28+
2729
/**
28-
* @TODO DESCR
30+
* Support of runkit on-the-fly userland code modification functionality
31+
* @var integer
2932
*/
3033
const SUPPORT_RUNKIT_MODIFY = 1;
34+
3135
/**
32-
* @TODO DESCR
36+
* Support of runkit on-the-fly internal code modification functionality
37+
* @var integer
3338
*/
3439
const SUPPORT_RUNKIT_INTERNAL_MODIFY = 2;
40+
3541
/**
36-
* @TODO DESCR
42+
* Support of runkit on-the-fly userland code import functionality
43+
* @var integer
3744
*/
3845
const SUPPORT_RUNKIT_IMPORT = 3;
46+
3947
/**
40-
* @TODO DESCR
48+
* Worker state: idle. It means that the worker IS NOT in the middle of execution valuable callback (e.g. request) at this moment of time. Currently, it does not mean that worker not have any pending operations.
49+
* @var integer
4150
*/
4251
const WSTATE_IDLE = 1;
52+
4353
/**
44-
* @TODO DESCR
54+
* Worker state: busy. It means that the worker IS in the middle of execution valuable callback.
4555
*/
4656
const WSTATE_BUSY = 2;
57+
4758
/**
48-
* @TODO DESCR
59+
* Worker state: shutdown. It means that worker is shutdown. Nothing special.
60+
* @var integer
4961
*/
5062
const WSTATE_SHUTDOWN = 3;
63+
5164
/**
52-
* @TODO DESCR
65+
* Worker state: shutdown. It means that worker is shutdown.
66+
* @var integer
5367
*/
5468
const WSTATE_PREINIT = 4;
69+
5570
/**
56-
* @TODO DESCR
71+
* Worker state: initialization. It means that worker is starting right now.
72+
* @var integer
5773
*/
58-
const WSTATE_WAITINIT = 5;
74+
const WSTATE_INIT = 5;
75+
5976
/**
60-
* @TODO DESCR
77+
* Hash of possible worker states
78+
* @var array
6179
*/
62-
const WSTATE_INIT = 6;
63-
64-
/** @var array */
6580
public static $wstateRev = [
6681
1 => 'IDLE',
6782
2 => 'BUSY',
6883
3 => 'SHUTDOWN',
6984
4 => 'PREINIT',
70-
5 => 'WAITINIT',
71-
6 => 'INIT',
85+
5 => 'INIT',
7286
];
87+
7388
/**
74-
* @TODO DESCR
89+
* Shared memory WSTATE segment size
90+
* @var integer
7591
*/
7692
const SHM_WSTATE_SIZE = 1024;
7793

@@ -93,7 +109,10 @@ class Daemon {
93109
*/
94110
public static $logpointer;
95111

96-
/** @var */
112+
/**
113+
* Log file async. resource
114+
* @var object
115+
*/
97116
public static $logpointerAsync;
98117

99118
/**
@@ -102,23 +121,58 @@ class Daemon {
102121
*/
103122
protected static $support = [];
104123

105-
/** @var \PHPDaemon\Thread\IPC|\PHPDaemon\Thread\Master|\PHPDaemon\Thread\Worker */
124+
/**
125+
* Current thread object
126+
* @var object \PHPDaemon\Thread\*
127+
*/
106128
public static $process;
107-
/** @var AppResolver */
129+
130+
/**
131+
* AppResolver
132+
* @var object \PHPDaemon\Core\AppResolver
133+
*/
108134
public static $appResolver;
109-
/** @var array */
135+
136+
/**
137+
* Running application instances
138+
* @var array
139+
*/
110140
public static $appInstances = [];
111-
/** @var \PHPDaemon\HTTPRequest\Generic */
141+
142+
/**
143+
* Running request
144+
* @var object \PHPDaemon\Request\Generic
145+
*/
112146
public static $req;
113-
/** @var */
147+
148+
/**
149+
* Running context
150+
* @var object
151+
*/
114152
public static $context;
115-
/** @var */
153+
154+
/**
155+
* Collection of workers
156+
* @var object \PHPDaemon\Thread\Collection
157+
*/
116158
protected static $workers;
117-
/** @var */
159+
160+
/**
161+
* Collection of masters
162+
* @var object \PHPDaemon\Thread\Collection
163+
*/
118164
protected static $masters;
119-
/** @var */
165+
166+
/**
167+
* Copy of $_SERVER on the daemon start
168+
* @var array
169+
*/
120170
protected static $initservervar;
121-
/** @var */
171+
172+
/**
173+
* Shared memory 'WSTATE' entity
174+
* @var object \PHPDaemon\Thread\Collection
175+
*/
122176
public static $shm_wstate;
123177

124178
/**
@@ -127,31 +181,60 @@ class Daemon {
127181
* @var boolean
128182
*/
129183
public static $reusePort = false;
130-
/** @var bool */
131-
public static $compatMode = FALSE;
132-
/** @var string */
184+
185+
/**
186+
* Running under Apache/PHP-FPM in compatibility mode?
187+
* @var boolean
188+
*/
189+
public static $compatMode = false;
190+
191+
/**
192+
* Base name of daemon instance
193+
* @var string
194+
*/
133195
public static $runName = 'phpdaemon';
134-
/** @var Config\Object */
196+
197+
/**
198+
* Configuration object
199+
* @var object \PHPDaemon\Config\Object
200+
*/
135201
public static $config;
136-
/** @var */
202+
203+
/**
204+
* Path to application resolver
205+
* @var string
206+
*/
137207
public static $appResolverPath;
138-
/** @var bool */
208+
209+
210+
/**
211+
* Restrict error control. When true, operator '@' means nothing.
212+
* @var boolean
213+
*/
139214
public static $restrictErrorControl = false;
140-
/** @var */
215+
216+
/**
217+
* Default error reporting level
218+
* @var integer
219+
*/
141220
public static $defaultErrorLevel;
221+
142222
/**
143-
* @TODO: refactoring
223+
* Is it running under master-less 'runworker' mode?
144224
* @var bool
145225
*/
146226
public static $runworkerMode = false;
147227

148228
/**
149-
* whether if the current execution stack contains ob-filter
229+
* Whether if the current execution stack contains ob-filter
150230
* @var bool
151231
*/
152232
public static $obInStack = false;
153233

154-
/** @var bool */
234+
/**
235+
* Mechanism of catching errors. Set it to true, then run your suspect code, and then check this property again. If false, there was error message.
236+
* @var bool
237+
*/
155238
public static $noError = false;
156239

157240
/**
@@ -304,7 +387,7 @@ public static function uncaughtExceptionHandler(\Exception $e) {
304387
* @param $errcontext
305388
*/
306389
public static function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
307-
Daemon::$noError = 0;
390+
Daemon::$noError = false;
308391
$l = error_reporting();
309392
if ($l === 0) {
310393
if (!Daemon::$restrictErrorControl) {
@@ -541,7 +624,6 @@ public static function getStateOfWorkers() {
541624
'alive' => 0,
542625
'shutdown' => 0,
543626
'preinit' => 0,
544-
'waitinit' => 0,
545627
'init' => 0,
546628
'reloading' => 0,
547629
];
@@ -587,12 +669,6 @@ public static function getStateOfWorkers() {
587669
++$stat['preinit'];
588670
++$stat['idle'];
589671
}
590-
elseif ($code === Daemon::WSTATE_WAITINIT) {
591-
// wait-init
592-
++$stat['alive'];
593-
++$stat['waitinit'];
594-
++$stat['idle'];
595-
}
596672
elseif ($code === Daemon::WSTATE_INIT) { // init
597673
++$stat['alive'];
598674
++$stat['init'];

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0-beta1
1+
1.0-beta3

0 commit comments

Comments
 (0)