-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.php
57 lines (47 loc) · 1.23 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Created by [BombSquad Inc](http://www.bmbsqd.com)
* User: Andy Hawkins
* Date: 4/10/15
* Time: 3:27 PM
*/
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();