There is no license information available for the latest version (0.2.0) of this package.

Pool implementation for pthreads

0.2.0 2014-02-09 21:46 UTC

This package is auto-updated.

Last update: 2022-05-19 09:17:41 UTC


An implementation of a thread pool for pthreads


namespace Camspiers\Pthreads;

require_once 'vendor/autoload.php';

class Job extends Work
    protected function process()
        // Do some work, and optionally return some data
        return range(1, 1000);

$pool = new Pool();

for ($i = 0; $i < 1000; $i++) {
    $pool->submitWork(new Job());

// get jobs as they finish
foreach ($pool->getFinishedJobs() as $job) {


Working with an autoloader

In pthreads you need to register a autoload in each thread (or worker). The can be achieved by setting a loader on the pool.

$loader = require 'vendor/autoload.php';

$pool = new \Camspiers\Pthreads\Pool();

// Use the pool