Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

laacz/php-threading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of PHP Threading

This is PHP-only implementation of threading (using pcntl_fork()).

Requirements

  • Decent PHP version (5.something, I believe).
  • PCNTL extension compiled in.

Example

<?php
class myThread extends Thread {
    
    function run() {
        $sleep = rand(1, 10);
        echo "{$this->name} Sleeping for {$sleep}s\n";
        sleep($sleep);
    }
    
    function finish() {
        echo "{$this->name} Done\n";
    }
    
    function stop() {
        $this->running = false;
    }
    
}

for ($i = 0 ; $i < 4; $i++) {
    new myThread();
}

Threading::join();

TODO

  • Implement transparent inter-process communication.
  • Add proper error handling.
  • Write tests.

About

Threading implemented in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages