Threading for PHP - Share Nothing

https://github.com/krakjoe/pthreads (5.x - 7.x)

https://github.com/krakjoe/pthreads-autoloading-composer

https://github.com/krakjoe/pthreads-polyfill

Примеры

$worker = new Worker(); $task = new class extends Threaded { public static $a; }; $task::$a = new class extends Threaded {}; $worker->start(); $worker->stack($task); $worker->shutdown();
$task = new class extends Threaded { public static $a; }; $task::$a = new class extends Threaded {}; $pool = new Pool(2); $pool->submit($task); $pool->shutdown();
<?php function demanding(...$params) { /* you have parameters here */ return array(rand(), rand()); } class Task extends Collectable { public function __construct(Threaded $result, $params) { $this->result = $result; $this->params = $params; } public function run() { $this->result[] = demanding(...$this->params); } protected $result; protected $params; } $pool = new Pool(16); $result = new Threaded(); while (@$i++<16) { $pool->submit( new Task($result, $argv)); } $pool->shutdown(); var_dump($result); ?>

Документация

http://docs.php.net/manual/ru/book.pthreads.php

Статьи

https://habrahabr.ru/post/300952/

PHP IPC — Межпроцессное взаимодействие в PHP