This project provides a POSIX-based multi-threaded programming mechanism for PHP. Any defined user-defined methods and functions can be executed asynchronously. Built-in support for sync and sync methods.
Highlights
- An easy-to-use, quick-to-learn Threading API for PHP5.3+
- Execute any and all predefined and user declared methods and functions asynchronously
- Ready made synchronization included, geared towards the PHP environment
- Seamless operation in multi-threaded SAPI environments
- A world of possibilities...
Technical Features
- Posix Threads
- Synchronization
- Worker Threads
- Synchronized Methods
- Complete Support for OO - ie. traits, interfaces, inheritance
- Full read/write/execute support for threaded objects
- Mutex (direct, subset)
- Conditions (direct, subset)
pthreads was written with simplicity, compatibility and efficiency in mind, it's performance beggars belief !!
Environmental requirements
- PHP5.3+
- ZTS Enabled (Thread Safety)
- Posix Threads Implementation
Testing has been carried out on x86, x64 and ARM, in general you just need a compiler and pthread.h
PHP version supported
pthreads should compile and work in any version of PHP from 5.3.0 to the latest release.
Sample code:
- class AsyncOperation extends Thread {
- public function __construct($arg){
- $this->arg = $arg;
- }
-
- public function run(){
- if($this->arg){
- printf("Hello %sn", $this->arg);
- }
- }
- }
- $thread = new AsyncOperation("World");
- if($thread ->start())
- $thread->join();
- ?>
Copy code
Project homepage:http://www.open-open.com/lib/view/ home/1391824675848
|