File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 9
9
class Pool{
10
10
11
11
protected int $ max_childs ;
12
+ protected bool $ kill_childs ;
12
13
protected array $ childs = [];
13
14
protected array $ queue = [];
14
15
protected int $ pid ;
@@ -18,14 +19,15 @@ class Pool{
18
19
private bool $ is_resolving_queue = false ;
19
20
private bool $ need_tick = true ;
20
21
21
- public function __construct (?int $ max_childs = null )
22
+ public function __construct (?int $ max_childs = null , bool $ kill_childs = true )
22
23
{
23
24
if (!extension_loaded ("pcntl " )){
24
25
throw new MissingExtensionException ("PCNTL Extension is missing in your PHP build " );
25
26
}
26
27
$ this ->pid = getmypid ();
27
28
$ max_childs ??= (self ::getCoresCount () ?? 1 ) * 50 ;
28
29
$ this ->max_childs = $ max_childs ;
30
+ $ this ->kill_childs = $ kill_childs ;
29
31
30
32
register_tick_function ([$ this , "tick " ]);
31
33
pcntl_signal (SIGCHLD , SIG_IGN ); // ignores the SIGCHLD signal
@@ -74,7 +76,9 @@ protected function _parallel(Closure $closure, ...$args)
74
76
else {
75
77
// we are the child
76
78
$ this ->is_parent = false ;
77
- pcntl_signal (SIGINT , SIG_IGN );
79
+ if (!$ this ->kill_childs ) {
80
+ pcntl_signal (SIGINT , SIG_IGN );
81
+ }
78
82
$ closure ($ args );
79
83
exit ;
80
84
}
You can’t perform that action at this time.
0 commit comments