1 | <?php |
||
10 | class InMemoryRules implements Rules |
||
11 | { |
||
12 | /** |
||
13 | * @var Rule[] |
||
14 | */ |
||
15 | protected $rules = array(); |
||
16 | |||
17 | /** |
||
18 | * @inheritdoc |
||
19 | * |
||
20 | * @param Rule $rule |
||
21 | * |
||
22 | * @return $this |
||
23 | */ |
||
24 | public function addRule(Rule $rule) |
||
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | * |
||
36 | * @param Rule $rule |
||
37 | * |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function removeRule(Rule $rule) |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | * |
||
54 | * @param Task $task |
||
55 | * @param Profile $profile |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function canRunTask(Task $task, Profile $profile) |
||
79 | |||
80 | /** |
||
81 | * Gets all the rules that apply to a task. |
||
82 | * |
||
83 | * @param Task $task |
||
84 | * |
||
85 | * @return Rule[] |
||
86 | */ |
||
87 | protected function getRulesForTask(Task $task) |
||
93 | |||
94 | /** |
||
95 | * Checks whether there are too many processes running to start a new one. |
||
96 | * |
||
97 | * @param Rule $rule |
||
98 | * @param Profile $profile |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | protected function hasTooManyProcessesRunning(Rule $rule, Profile $profile) |
||
106 | |||
107 | /** |
||
108 | * Checks whether the current profile is within the constraints of a rule. |
||
109 | * |
||
110 | * @param Rule $rule |
||
111 | * @param Profile $profile |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | protected function withinConstraints(Rule $rule, Profile $profile) |
||
119 | |||
120 | /** |
||
121 | * Checks whether the current profile is within the processor constraints of a rule. |
||
122 | * |
||
123 | * @param Rule $rule |
||
124 | * @param Profile $profile |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | protected function withinProcessorConstraints(Rule $rule, Profile $profile) |
||
136 | |||
137 | /** |
||
138 | * Checks whether the current profile is within the memory constraints of a rule. |
||
139 | * |
||
140 | * @param Rule $rule |
||
141 | * @param Profile $profile |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | protected function withinMemoryConstraints(Rule $rule, Profile $profile) |
||
153 | |||
154 | /** |
||
155 | * Checks whether there are too many sibling processes running to start a new one. |
||
156 | * |
||
157 | * @param Rule $rule |
||
158 | * @param Profile $profile |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | protected function hasTooManySiblingProcessesRunning(Rule $rule, Profile $profile) |
||
166 | |||
167 | /** |
||
168 | * Checks whether the profile or sibling processes is within the constraints of a rule. |
||
169 | * |
||
170 | * @param Rule $rule |
||
171 | * @param Profile $profile |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | protected function withinSiblingConstraints(Rule $rule, Profile $profile) |
||
179 | |||
180 | /** |
||
181 | * Checks whether the profile or sibling processes is within the processor constraints of a rule. |
||
182 | * |
||
183 | * @param Rule $rule |
||
184 | * @param Profile $profile |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | protected function withinSiblingProcessorConstraints(Rule $rule, Profile $profile) |
||
196 | |||
197 | /** |
||
198 | * Checks whether the profile or sibling processes is within the memory constraints of a rule. |
||
199 | * |
||
200 | * @param Rule $rule |
||
201 | * @param Profile $profile |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | protected function withinSiblingMemoryConstraints(Rule $rule, Profile $profile) |
||
213 | } |
||
214 |