Skip to content

Commit 0475cad

Browse files
committed
add $process_title
1 parent 06aa368 commit 0475cad

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Pool.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function enqueue(Closure $closure, array $args): void
5959
// TODO enqueue args
6060
}
6161

62-
protected function _parallel(Closure $closure, ...$args)
62+
protected function _parallel(Closure $closure, string $process_title = null, ...$args)
6363
{
6464
self::breakpoint("started a parallel");
6565
self::breakpoint("parallel can be done: current childs: ".count($this->childs)."/".$this->max_childs);
@@ -79,12 +79,15 @@ protected function _parallel(Closure $closure, ...$args)
7979
if (!$this->kill_childs) {
8080
pcntl_signal(SIGINT, SIG_IGN);
8181
}
82+
if(isset($process_title)){
83+
@cli_set_process_title($process_title);
84+
}
8285
$closure($args);
8386
exit;
8487
}
8588
}
8689

87-
public function parallel(Closure $closure, ...$args)
90+
public function parallel(Closure $closure, string $process_title = null, ...$args)
8891
{
8992
if(!empty($this->queue)){
9093
self::breakpoint("resolving queue before parallel()");
@@ -103,7 +106,7 @@ public function parallel(Closure $closure, ...$args)
103106
elseif(count($this->childs) > $this->max_childs/2){
104107
$this->checkChilds();
105108
}
106-
return $this->_parallel($closure, ...$args);
109+
return $this->_parallel($closure, $process_title, ...$args);
107110
}
108111

109112
public function resolveQueue()

0 commit comments

Comments
 (0)