Skip to content

Commit 14f7051

Browse files
committed
Upd readme
1 parent ae69f95 commit 14f7051

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,43 @@ Use at your own risk.
88
Check out examples in `examples/` dir.
99

1010
No tests – no problems.
11+
12+
Example explain features
13+
========================
14+
15+
```php
16+
use EProcess\Worker;
17+
18+
class Data
19+
{
20+
// jms serializer metadata
21+
private $id;
22+
// setters getters etc.
23+
}
24+
25+
class Main // like that one in c++
26+
{
27+
public function run()
28+
{
29+
$worker = $this->createWorker(MyWorker::class); // create external non-blocking thread of MyWorker class
30+
$worker->event('any_event', 'Hello my worker!');
31+
$worker->on('hello_master', function() {
32+
// Receive back-call from child
33+
});
34+
}
35+
}
36+
37+
class MyWorker extends Worker
38+
{
39+
public function run()
40+
{
41+
$this->on('any_event', function($data) {
42+
echo 'Got any_event event from my master: ' . $data; // data == Hello my worker
43+
// Still we can send any event back to master
44+
$this->event('hello_master');
45+
});
46+
}
47+
}
48+
```
49+
50+
You need to have proper autoloading established in order to use this example.

0 commit comments

Comments
 (0)