SkillAgentSearch skills...

MultiPhreading

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

Install / Use

/learn @a904guy/MultiPhreading
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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();

Related Skills

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated11mo ago
Forks1

Languages

PHP

Security Score

62/100

Audited on Apr 18, 2025

No findings