2017 © Pedro Peláez
 

library pthreads-pool

Pool implementation for pthreads

image

camspiers/pthreads-pool

Pool implementation for pthreads

  • Sunday, February 9, 2014
  • by camspiers
  • Repository
  • 2 Watchers
  • 8 Stars
  • 227 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Pthreads Pool

An implementation of a thread pool for pthreads, (*1)

Example

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) {
    var_dump($job->getData());
}

$pool->shutdown();

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., (*2)

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

$pool = new \Camspiers\Pthreads\Pool();
$pool->setLoader($loader);

// Use the pool

The Versions

09/02 2014

dev-master

9999999-dev

Pool implementation for pthreads

  Sources   Download

The Requires

  • php >=5.5.0

 

09/02 2014

0.2.0

0.2.0.0

Pool implementation for pthreads

  Sources   Download

The Requires

  • php >=5.5.0

 

08/02 2014

0.1.0

0.1.0.0

Pool implementation for pthreads

  Sources   Download

The Requires

  • php >=5.5.0