Skip to content

PHP Multi Process Threading, Shared Memory Berkley Keystore, Message Queue system.

Notifications You must be signed in to change notification settings

a904guy/MultiPhreading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MultiPhreading

PHP Multi Process Threading, Shared Memory Berkley Keystore, Message Queue system.

Example of all above

include "lib/Threading.php";
use \MultiPhreading\Threading;
use \MultiPhreading\Runnable;
use \MultiPhreading\SharedMemory;
use \MultiPhreading\SharedQueue;
class testRunnable implements Runnable {
	function run() {
		echo "\nHello, This is threaded speaking.";
		echo "\nReading From SharedMemory";
		$sham = new SharedMemory('MSQ');
		echo "\nHello ".$sham->Hello;
		echo "\nAndy ".json_encode($sham->Andy);
		$msq = new SharedQueue();
		echo "\nReading Queue. Total Messages: ".$msq->size();
		foreach($msq->fetch() as $msg)
		{
			echo "\n".$msg;
			break;
		}
		sleep(300);
		echo "\nHanging up\n\n";
	}
}
echo "\nStuffing SharedMemory.";
$sham = new SharedMemory('MSQ');
$sham->Hello = 'World';
$sham->Andy = ['Rocks'];
$msq = new SharedQueue();
foreach(range(1,3) as $n)
	$msq->publish('Threaded Queue Message: '.$n);
echo "\nStarting Thread";
Threading::run(new testRunnable());
Threading::run(new testRunnable());
Threading::run(new testRunnable());
echo "\nHello, This is master, Are you there thread?";
sleep(1);
echo "\n"; passthru('ps aux | grep php | grep test');
sleep(300);
echo "\nHanging up\n\n";
exit();

About

PHP Multi Process Threading, Shared Memory Berkley Keystore, Message Queue system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages