-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMyWork.php
More file actions
34 lines (27 loc) · 741 Bytes
/
MyWork.php
File metadata and controls
34 lines (27 loc) · 741 Bytes
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
<?php
/**
* MyWork is task what may be executed parallelly
*/
class MyWork extends Threaded
{
public function run()
{
do {
$value = null;
$provider = $this->worker->getProvider();
// Syncronize receiving data
$provider->synchronized(function($provider) use (&$value) {
$value = $provider->getNext();
}, $provider);
if ($value === null) {
continue;
}
// Some resource intensive operation
$count = 100;
for ($j = 1; $j <= $count; $j++) {
sqrt($j+$value) + sin($value/$j) + cos($value);
}
}
while ($value !== null);
}
}