Skip to content

Commit 9c7da6c

Browse files
committed
PCNTL is no longer required, an Error will be thrown if not present
1 parent f73fbd0 commit 9c7da6c

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
}
1111
],
1212
"require":{
13-
"php":">=7.4",
14-
"ext-pcntl":"*"
13+
"php":">=7.4"
1514
},
1615
"autoload": {
1716
"psr-4":{

src/Pool.php

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class Pool{
2020

2121
public function __construct(?int $max_childs = null)
2222
{
23+
if(!extension_loaded("pcntl")){
24+
throw new \Error("PCNTL Extension is missing in your PHP build");
25+
}
2326
$this->pid = getmypid();
2427
$max_childs ??= (self::getCoresCount() ?? 1) * 50;
2528
$this->max_childs = $max_childs;
@@ -38,15 +41,6 @@ public function checkChilds()
3841
self::breakpoint("Removed child n. $key");
3942
$removed = true;
4043
}
41-
/*else{
42-
$this->internalParallel();
43-
if(!self::isProcessRunning($child)){
44-
unset($this->childs[$key]);
45-
self::breakpoint("Removed child n. $key from retrying");
46-
$removed = true;
47-
}
48-
49-
}*/
5044
}
5145
if(!$removed){
5246
self::breakpoint("CheckChilds didn't remove any child");
@@ -59,23 +53,7 @@ public function enqueue(Closure $closure, array $args): void
5953
$this->queue[] = fn() => $closure($args);
6054
// TODO enqueue args
6155
}
62-
/*
63-
public function internalParallel(){
64-
$pid = pcntl_fork();
65-
if ($pid == -1) {
66-
die('could not fork');
67-
}
68-
elseif($pid){
69-
// we are the parent
70-
pcntl_wait($status, WNOHANG);
71-
}
72-
else{
73-
// we are the child
74-
$this->is_parent = false;
75-
exit;
76-
}
77-
}
78-
*/
56+
7957
protected function _parallel(Closure $closure, ...$args)
8058
{
8159
self::breakpoint("started a parallel");

0 commit comments

Comments
 (0)