1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author: stev leibelt <[email protected]> |
4
|
|
|
* @since: 31.07.2014 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Net\Bazzline\Component\ProcessForkManager; |
8
|
|
|
|
9
|
|
|
use Symfony\Component\EventDispatcher\Event; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ForkManagerEvent |
13
|
|
|
* @package Net\Bazzline\Component\ProcessForkManager |
14
|
|
|
*/ |
15
|
|
|
class ForkManagerEvent extends Event |
16
|
|
|
{ |
17
|
|
|
const FINISHED_EXECUTION = 'forkManager.execution.finished'; |
18
|
|
|
const FINISHED_EXECUTION_OF_OPEN_TASK = 'forkManager.task.open.finished'; |
19
|
|
|
const FINISHED_TASK = 'forkManager.task.execution.finished'; |
20
|
|
|
const FINISHED_WAITING_FOR_RUNNING_TASKS = 'forkManager.task.waiting_for_running.finished'; |
21
|
|
|
|
22
|
|
|
const REACHING_MEMORY_LIMIT = 'forkManager.limit.memory.reached'; |
23
|
|
|
const REACHING_TIME_LIMIT = 'forkManager.limit.time.reached'; |
24
|
|
|
|
25
|
|
|
const STARTING_EXECUTION = 'forkManager.execution.started'; |
26
|
|
|
const STARTING_EXECUTION_OF_OPEN_TASK = 'forkManager.task.open.started'; |
27
|
|
|
const STARTING_TASK = 'forkManager.task.execution.open.started'; |
28
|
|
|
const STARTING_WAITING_FOR_RUNNING_TASKS = 'forkManager.task.waiting_for_running.started'; |
29
|
|
|
|
30
|
|
|
const STOPPING_EXECUTION = 'forkManager.execution.stopped'; |
31
|
|
|
const STOPPING_TASK = 'forkManager.thread.stopped'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ForkManager |
35
|
|
|
*/ |
36
|
|
|
private $forkManager; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $source; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var TaskInterface |
45
|
|
|
*/ |
46
|
|
|
private $task; |
47
|
|
|
|
48
|
|
|
public function __clone() |
49
|
|
|
{ |
50
|
|
|
$this->forkManager = null; |
51
|
|
|
$this->source = null; |
52
|
|
|
$this->task = null; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return ForkManager |
57
|
|
|
*/ |
58
|
|
|
public function getForkManager() |
59
|
|
|
{ |
60
|
|
|
return $this->forkManager; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return bool |
65
|
|
|
*/ |
66
|
|
|
public function hasForkManager() |
67
|
|
|
{ |
68
|
|
|
return ($this->forkManager instanceof ForkManager); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param null|ForkManager $manager |
73
|
|
|
*/ |
74
|
|
|
public function setForkManager(ForkManager $manager) |
75
|
|
|
{ |
76
|
|
|
$this->forkManager = $manager; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return null|string |
81
|
|
|
*/ |
82
|
|
|
public function getSource() |
83
|
|
|
{ |
84
|
|
|
return $this->source; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function hasSource() |
91
|
|
|
{ |
92
|
|
|
return (!is_null($this->source)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $source |
97
|
|
|
*/ |
98
|
|
|
public function setSource($source) |
99
|
|
|
{ |
100
|
|
|
$this->source = (string) $source; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return null|TaskInterface |
105
|
|
|
*/ |
106
|
|
|
public function getTask() |
107
|
|
|
{ |
108
|
|
|
return $this->task; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return bool |
113
|
|
|
*/ |
114
|
|
|
public function hasTask() |
115
|
|
|
{ |
116
|
|
|
return ($this->task instanceof TaskInterface); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param TaskInterface $task |
121
|
|
|
*/ |
122
|
|
|
public function setTask(TaskInterface $task) |
123
|
|
|
{ |
124
|
|
|
$this->task = $task; |
125
|
|
|
} |
126
|
|
|
} |