1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00
Go to file
2017-06-21 18:20:06 +02:00
bin Exit when parent context dies 2017-06-19 11:15:41 -05:00
examples Fix code style 2017-06-17 18:31:35 +02:00
lib Remove -- when invoking the PHP CLI binary 2017-06-21 18:20:06 +02:00
test Quiet CS fixer… remove used import 2017-06-19 11:24:39 -05:00
travis Fix permissions 2017-05-18 17:21:52 -05:00
.gitattributes example → examples 2017-06-16 00:04:10 -05:00
.gitignore Apply Amp's code style 2017-05-18 09:51:31 +02:00
.php_cs.dist Fix php-cs-fixer config 2017-06-17 18:23:28 +02:00
.travis.yml Fix Travis build for PHP 7.2 2017-06-17 18:18:29 +02:00
.valgrindrc Add helpful defaults for Valgrind 2015-08-27 12:33:19 -05:00
composer.json Used tagged process version 2017-06-16 00:02:20 -05:00
CONTRIBUTING.md Port to Amp 2016-08-18 11:04:48 -05:00
LICENSE Update license 2015-09-14 21:28:25 -05:00
Makefile Apply Amp's code style 2017-05-18 09:51:31 +02:00
phpdoc.dist.xml Port to Amp 2016-08-18 11:04:48 -05:00
phpunit.xml.dist Update to PHPUnit 6 and use helper package 2017-03-21 23:19:15 -05:00
README.md Rename to Parallel 2016-08-23 16:47:40 -05:00
Vagrantfile Update vagrant box for PHP 7 2016-01-23 10:50:56 -06:00

Parallel Processing for Amp

True parallel processing using native threading and multiprocessing for parallelizing code, without blocking.

This library is a component for Amp that provides native threading, multiprocessing, process synchronization, shared memory, and task workers. Like other Amp components, this library uses Coroutines built from Awaitables and Generators to make writing asynchronous code more like writing synchronous code.

This library provides a means of parallelizing code without littering your application with complicated lock checking and inter-process communication.

To be as flexible as possible, this library comes with a collection of non-blocking concurrency tools that can be used independently as needed, as well as an "opinionated" worker API that allows you to assign units of work to a pool of worker threads or processes.

Requirements
  • PHP 7 (no extensions required)
Suggested
  • pthreads extension: Best extension option for concurrency in PHP, but it requires PHP to be compiled with --enable-maintainer-zts to enable thread-safety.
  • pcntl extension: Enables forking concurrency method.
  • sysvmsg extension: Required for sharing memory between forks or processes.
Installation

The recommended way to install is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)

Run the following command to use this package in your project:

composer require amphp/parallel

You can also manually edit composer.json to add this library as a project requirement.

// composer.json
{
    "require": {
        "amphp/parallel": "dev-master"
    }
}

Development and Contributing

Want to hack on the source? A Vagrant box is provided with the repository to give a common development environment for running concurrent threads and processes, and comes with a bunch of handy tools and scripts for testing and experimentation.

Starting up and logging into the virtual machine is as simple as

vagrant up && vagrant ssh

Once inside the VM, you can install PHP extensions with Pickle, switch versions with newphp VERSION, and test for memory leaks with Valgrind.