aza / thread
AzaThread - Anizoptera CMF simple and powerful threads emulation component for PHP (based on forks).
Installs: 28 350
Dependents: 3
Suggesters: 0
Security: 0
Stars: 72
Watchers: 8
Forks: 11
Open Issues: 3
Requires
- php: >=5.3.3
- aza/clibase: ~1.0
- aza/libevent: ~1.0
- aza/socket: ~1.0
Suggests
- ext-libevent: Only synchronous compatibility mode will be available without it
- ext-pcntl: Only synchronous compatibility mode will be available without it
- ext-posix: Only synchronous compatibility mode will be available without it
This package is not auto-updated.
Last update: 2024-12-21 15:44:36 UTC
README
Simple and powerful threads emulation component for PHP (based on forks). Old name - CThread.
https://github.com/Anizoptera/AzaThread
Table of Contents
Introduction
Features:
- Uses forks to operate asynchronously;
- Supports synchronous compatibility mode if there are no required extensions;
- Reuse of the child processes;
- Full exchange of data between processes. Sending arguments, receiving results;
- Transfer of events between the "thread" and the parent process;
- Working with a thread pool with preservation of multiple use, passing arguments and receiving results;
- Uses libevent with socket pairs for efficient inter-process communication;
- Supports two variants of data serialization for transfer (igbinary, native php serialization);
- Errors handling;
- Timeouts for work, child process waiting, initialization;
- Maximum performance and customization;
Requirements
- PHP 5.3.3 (or later);
- Unix system;
- libevent;
- pcntl;
- posix;
- AzaLibevent - will be installed automatically with composer;
- AzaSocket - will be installed automatically with composer;
- AzaCliBase - will be installed automatically with composer;
NOTE: You can use synchronous compatibility mode even without requirements (or on windows, for example).
Installation
The recommended way to install AzaThread is through composer. You can see package information on Packagist.
{ "require": { "aza/thread": "~1.0" } }
Documentation and examples
See full documentation and main examples. Documentation is available in several languages!
Other examples can be seen in the file examples/example.php and in unit test Tests/ThreadTest.php.
You can also run the performance tests, choose the number of threads and pick the best settings for your system configuration by using examples/speed_test.php.
Tests
Tests are in the Tests
folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
Credits
AzaThread is a part of Anizoptera CMF, written by Amal Samally (amal.samally at gmail.com) and AzaGroup team.
License
Released under the MIT license.
Links
- Mail list (via Google Group)
- Composer package
- Last build on the Travis CI
- Project profile on the Ohloh
- (RU) AzaThread — многопоточность для PHP с блэкджеком
- Other Anizoptera CMF components on the GitHub / Packagist
- (RU) AzaGroup team blog