noccylabs/async

$ git tag
0.1.0

$ git branch
* master

noccylabs/async

This is a library to help manage "threads" spawned through forking. It contains a core Thread class as well as a number of utility classes such as ThreadPool that efficiently executes a queue of threads.

Spawning threads

use NoccyLabs\Async\Thread;

function myThreadFunc() {
    // ..
}

$thread = new Thread("myThreadFunc");
$thread->start();

// Wait for the thread using one of these
Thread::wait($thread, $otherThread, ...);
$thread->waitForThread();

Managing a pool

use NoccyLabs\Async\Thread;
use NoccyLabs\Async\ThreadPool;

// Use 3 concurrent threads
$pool = new ThreadPool(3);
// Add your threads to the pool
$pool->addThreads($myThreads);
// Start processing the queue
$pool->run();