1
|
|
|
<?php namespace Comodojo\Daemon\Worker; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Daemon\Traits\PidTrait; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @package Comodojo Daemon |
7
|
|
|
* @author Marco Giovinazzi <[email protected]> |
8
|
|
|
* @license MIT |
9
|
|
|
* |
10
|
|
|
* LICENSE: |
11
|
|
|
* |
12
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
13
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
14
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
15
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
16
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
17
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
18
|
|
|
* THE SOFTWARE. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
class Worker { |
22
|
|
|
|
23
|
|
|
use PidTrait; |
24
|
|
|
|
25
|
|
|
protected $instance; |
26
|
|
|
|
27
|
|
|
protected $looptime; |
28
|
|
|
|
29
|
|
|
protected $is_forever; |
30
|
|
|
|
31
|
|
|
protected $input_channel; |
32
|
|
|
|
33
|
|
|
protected $output_channel; |
34
|
|
|
|
35
|
|
|
public static function create() { |
36
|
|
|
|
37
|
|
|
return new Worker(); |
38
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getInstance() { |
42
|
|
|
|
43
|
|
|
return $this->instance; |
44
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function setInstance($instance) { |
48
|
|
|
|
49
|
|
|
$this->instance = $instance; |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getLooptime() { |
56
|
|
|
|
57
|
|
|
return $this->looptime; |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setLooptime($looptime) { |
62
|
|
|
|
63
|
|
|
$this->looptime = $looptime; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getForever() { |
70
|
|
|
|
71
|
|
|
return $this->forever; |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setForever($forever) { |
76
|
|
|
|
77
|
|
|
$this->forever = $forever; |
|
|
|
|
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getInputChannel() { |
84
|
|
|
|
85
|
|
|
return $this->input_channel; |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function setInputChannel($input) { |
90
|
|
|
|
91
|
|
|
$this->input_channel = $input; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getOutputChannel() { |
98
|
|
|
|
99
|
|
|
return $this->output_channel; |
100
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setOutputChannel($output) { |
104
|
|
|
|
105
|
|
|
$this->output_channel = $output; |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
|
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
|