File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,43 @@ Use at your own risk.
8
8
Check out examples in ` examples/ ` dir.
9
9
10
10
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.
You can’t perform that action at this time.
0 commit comments