PHP Classes

Multi-thread Simulation: Emulate threads using separate HTTP requests

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStar 35%Total: 6,363 This week: 1All time: 334 This week: 560Down
Version License PHP version Categories
thread 0.0GNU General Publi...4.0HTTP, Tools, Language
Description 

Author

This class can emulate the execution of program threads using separate HTTP requests to the same script.

It establishes an HTTP connection to the same Web server to execute the same PHP script. It sends a request passing the name a function to execute and an argument to be passed to that function.

The requested script executes some code that detects the thread execution request and calls the specified function.

When the thread request script ends, the return values of the called function is returned as a serialized string.

The calling script can execute other tasks while the thread script runs. The results may be collected later when the thread script ends.

Innovation Award
PHP Programming Innovation award nominee
July 2007
Number 2


Prize: One book of choice by O'Reilly
Some applications need to perform several tasks that may take a while to finish. When there are many tasks to execute, it may take a long time to finish all of them if they are executed sequentially, i.e. one after another.

A possible solution for this problem is to execute several tasks at the same time using separate processes or threads.

PHP has the pcntl extension that can be used to run multiple processes in parallel. However, this extension is only available in Linux or Unix like operating systems.

This package provides an alternative solution that consists in sending multiple HTTP requests to the same Web server on which PHP is running.

Each HTTP request triggers the execution of a different task. Many requests can be run at the same time without having to wait for each one to finish.

This solution can run in Windows and all other operating systems supported by PHP, including PHP environments on which the pcntl extension is not installed.

Manuel Lemos
Picture of Alex Lau
Name: Alex Lau is available for providing paid consulting. Contact Alex Lau .
Classes: 3 packages by
Country: Hong Kong Hong Kong
Age: 35
All time rank: 3522 in Hong Kong Hong Kong
Week rank: 411 Down1 in Hong Kong Hong Kong Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Accessible without login Plain text file test.php Example An example
Plain text file Thread.php Class The main class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:6,363
This week:1
All time:334
This week:560Down
User Ratings User Comments (1)
 All time
Utility:50%StarStarStar
Consistency:50%StarStarStar
Documentation:-
Examples:50%StarStarStar
Tests:-
Videos:-
Overall:35%StarStar
Rank:4077