This is a tutorial of the krakjoe/pthreads extension v3 for PHP7
.
Follow the instructions below:
$ cd <php-source-directory>
$ ./configure --enable-maintainer-zts ...
$ make
$ make install
Download the latest 3.x release from Pecl
$ cd <php-source-directory>/ext
$ mkdir pthreads
$ tar zxf <path-to-pthreads-src-tarball> -C pthreads --strip-components=1
$ phpize
$ ./configure
$ make
$ sudo make install
$ # This will install the pthreads.so to php extension directory
$ # load pthreads.so in php.ini
-
Tests/Pthreads/BasicProducerConsumerTest.php
- a producer/consumer example with threads. -
Tests/Pthreads/WorkerProducerConsumer.php
- a producer/consumer example with threads and workers. -
Tests/Pthreads/PoolProducerConsumer.php
- a producer/consumer example with threads, workers and pools. -
Tests/Pthreads/IssueArrayPropertyTest.php
- an example to demonstrate array can't be used as properties of threaded object. -
Tests/Pthreads/IssueNonThreadedPropertyTest.php
- an example to demonstrate how non-threaded properties are broken in multi-threading environment. -
Tests/Pthreads/Issue602Test.php
- The script for reproducing issue #602. -
Tests/Pthreads/Issue603Test.php
- The script for reproducing issue #603. -
Tests/Pthreads/IssueLocalVariableTest.php
- The script to demonstrate local variables in pthreads are destroyed. -
Tests/Pthreads/PropertyOfThreadedAndVolatileTest.php
- The script to demonstrate different accessibilities of threaded and volatile objects.
The ZerusTech Pthreads Tutorial is published under the MIT License.