PHPackages                             axxapy/php\_threadpool - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. axxapy/php\_threadpool

ActiveLibrary

axxapy/php\_threadpool
======================

Thread &amp;&amp; Thread pool wrappers for pcntl (not actual threads but forks)

v1.0.1(6y ago)0131MITPHP

Since Apr 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/axxapy/php_threadpool)[ Packagist](https://packagist.org/packages/axxapy/php_threadpool)[ RSS](/packages/axxapy-php-threadpool/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

Single thread
=============

[](#single-thread)

Example:

```
$Threads = [];
$Threads[] = new Thread(function(Thread $Thread) {
	$Thread->saveData(file_get_contents($Thread->getLaunchParams()[0]));
});
$Threads[] = clone $Threads[0];
$Threads[] = clone $Threads[0];

$Threads[0]->run('http://ya.ru');
$Threads[1]->run('http://mail.ru');
$Threads[2]->run('http://r0.ru');

while (array_filter($Threads, function (Thread $Thread) {return $Thread->isChildAlive();})) {
	sleep(1);
}

array_walk($Threads, function(Thread $Thread) {
	var_dump($Thread->getSavedResult());
});
```

ThreadPool
==========

[](#threadpool)

- Allows to execute unlimited number of threads.
- Manages child tasks and respawns them if they died without setting their status as "complete".
- It is useful to execute scripts with memory leak.
- Can be used for daemon implementation. Example:

```
$res = (new ThreadPool(10)) //threads count
	->setTask(function (Thread $Thread) {
		$data = $Thread->getSavedData();
		$i = isset($data['i']) ? $data['i'] : 0;
		$i++;
		var_dump($i);

		$Thread->saveResult([
			'i'   => $i,
			'num' => $Thread->getThreadNumber(),
		]);

		if ($i >= 10) {//script will exit after 10 iterations/launches
			$Thread->markFinished();
		}
	})->setInterruptedHandler(function (Thread $Thread, $signo) {
		//dump current state before exit
		file_put_contents('worker_' . $Thread->getThreadNumber(), json_encode($Thread->getSavedResult()));
		trigger_error('Interrupted with signal ' . $signo);
	})->run();

var_dump($res);

// will return [
//     0 => [
//         'i'   => 10,
//         'num' => 0
//     ],
//     1 => [
//         'i'   => 10,
//         'num' => 1
//     ]
// ];
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

2224d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7d168d3b56ab59daf58b494a0c670e730fd4f177cb11c2ec91ddfd547afaf8f?d=identicon)[axxapy](/maintainers/axxapy)

---

Top Contributors

[![axxapy](https://avatars.githubusercontent.com/u/3088476?v=4)](https://github.com/axxapy "axxapy (6 commits)")

### Embed Badge

![Health badge](/badges/axxapy-php-threadpool/health.svg)

```
[![Health](https://phpackages.com/badges/axxapy-php-threadpool/health.svg)](https://phpackages.com/packages/axxapy-php-threadpool)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
