Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-11-06 (Yesterday) | Not yet rated by the users | Total: 1 This week: 1 | All time: 11,480 This week: 63 |
Version | License | PHP version | Categories | |||
generic-executor-ser 1.0 | GNU General Publi... | 8 | Unix, Language, Performance and optim..., P... |
Description | Author | |
This package can execute multiple functions in parallel. |
Follow example code provided in example.php file.
<?php |
A Generic Executor Service in PHP for asynchronous calls.
This repository demonstrates a basic implementation of a Generic Executor Service in PHP 8 using the `
pcntl`
extension to handle concurrency. It mimics the behavior of Java's ExecutorService by managing a pool of "workers" (processes) that execute tasks asynchronously.
generic-executor-service-php a language port from Java to PHP from the repository which I created a while ago called generic-executor-service-java (https://github.com/niteshapte/generic-executor-service-java)
Clone the repository:
git clone https://github.com/your-username/generic-executor-service-php.git
cd generic-executor-service-php
Ensure you have `
pcntl`
enabled in your PHP environment.
Run the script using the PHP CLI:
php executor.php
`
pcntl`
The `
GenericExecutorService`
relies on the `
pcntl_fork()`
function to create separate processes for each task. This provides concurrency in environments where PHP doesn't natively support multi-threading. However, `
pcntl`
is only available in CLI and POSIX-compliant environments (Linux/macOS).
## Customization
You can modify the following aspects of the service:
- Max Workers: Control the maximum number of concurrent workers by passing an integer to the GenericExecutorService constructor.
- Task Length: Simulate longer or shorter tasks by adjusting the sleep duration inside the tasks.
## Contribution
Contributions are welcome! If you'd like to improve this project, feel free to fork the repository and submit a pull request.
### Steps to Contribute:
1. Fork this repository by clicking the Fork button at the top right.
2. Clone your fork locally:
git clone https://github.com/your-username/generic-executor-service-php.git
3. Create a new branch for your feature or fix:
git checkout -b feature-branch
4. Make your changes and commit them:
git commit -m "Description of your changes"
5. Push to your fork:
git push origin feature-branch
6. Open a pull request on the original repository.
Feel free to suggest improvements, refactorings, or new features! All contributions, no matter how small, are greatly appreciated.
Files (4) |
File | Role | Description |
---|---|---|
example.php | Example | Example script |
GenericExecutorService.php | Class | Class source |
LICENSE | Lic. | License text |
README.md | Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.