@@ -26,7 +26,7 @@ |
||
26 | 26 | public function toArray() |
27 | 27 | { |
28 | 28 | return array_map( |
29 | - function ($result) { |
|
29 | + function($result) { |
|
30 | 30 | return $result->getReturn(); |
31 | 31 | }, |
32 | 32 | $this->results |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | foreach ($this->signals as $sig) { |
61 | 61 | $this->pcntl->signal( |
62 | 62 | $sig, |
63 | - function ($sig) use($log, $self) { |
|
64 | - $log->info('received signal. signo: ' . $sig); |
|
63 | + function($sig) use($log, $self) { |
|
64 | + $log->info('received signal. signo: '.$sig); |
|
65 | 65 | $self->setReceivedSignal($sig); |
66 | 66 | |
67 | 67 | $log->info('--> sending a signal " to children.'); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - $this->log->info('parent pid: ' . $this->ownerPid); |
|
76 | + $this->log->info('parent pid: '.$this->ownerPid); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | throw $e; |
112 | 112 | } |
113 | 113 | |
114 | - $this->log->info('queued task #' . $this->container->queuedCount()); |
|
114 | + $this->log->info('queued task #'.$this->container->queuedCount()); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $this->wait(); |
155 | 155 | } |
156 | 156 | if ($tag !== null && !$this->container->hasTag($tag)) { |
157 | - throw new \InvalidArgumentException('unknown tag: ' . $tag); |
|
157 | + throw new \InvalidArgumentException('unknown tag: '.$tag); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | return $this->container->getCollection($tag); |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | $this->ownerPid = $ownerPid; |
22 | 22 | $this->prefix = $prefix; |
23 | - $this->pathname = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->prefix . $this->ownerPid; |
|
23 | + $this->pathname = sys_get_temp_dir().DIRECTORY_SEPARATOR.$this->prefix.$this->ownerPid; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(ticks=1); |
|
2 | +declare(ticks = 1); |
|
3 | 3 | |
4 | 4 | namespace Ackintosh\Snidel; |
5 | 5 |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $type, |
71 | 71 | $pid, |
72 | 72 | $role, |
73 | - $message . PHP_EOL |
|
73 | + $message.PHP_EOL |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | if (getmypid() === $this->ownerPid) { |
148 | 148 | // owner |
149 | - $this->log->info('pid: ' . getmypid()); |
|
149 | + $this->log->info('pid: '.getmypid()); |
|
150 | 150 | $this->taskQueue = $this->queueFactory->createTaskQueue(); |
151 | 151 | $this->resultQueue = $this->queueFactory->createResultQueue(); |
152 | 152 | |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | } else { |
155 | 155 | // master |
156 | 156 | $activeWorkerSet = new ActiveWorkerSet(); |
157 | - $this->log->info('pid: ' . $this->masterPid); |
|
157 | + $this->log->info('pid: '.$this->masterPid); |
|
158 | 158 | |
159 | 159 | // for php5.3 |
160 | 160 | $log = $this->log; |
161 | 161 | $receivedSignal = &$this->receivedSignal; |
162 | 162 | foreach ($this->signals as $sig) { |
163 | - $this->pcntl->signal($sig, function ($sig) use ($log, $activeWorkerSet, $receivedSignal) { |
|
163 | + $this->pcntl->signal($sig, function($sig) use ($log, $activeWorkerSet, $receivedSignal) { |
|
164 | 164 | $receivedSignal = $sig; |
165 | - $log->info('received signal: ' . $sig); |
|
165 | + $log->info('received signal: '.$sig); |
|
166 | 166 | |
167 | 167 | if ($activeWorkerSet->count() === 0) { |
168 | 168 | $log->info('no worker is active.'); |
169 | 169 | } else { |
170 | - $log->info('------> sending signal to workers. signal: ' . $sig); |
|
170 | + $log->info('------> sending signal to workers. signal: '.$sig); |
|
171 | 171 | $activeWorkerSet->terminate($sig); |
172 | 172 | $log->info('<------ sent signal'); |
173 | 173 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | }); |
176 | 176 | } |
177 | 177 | |
178 | - $concurrency = (int)$this->config->get('concurrency'); |
|
178 | + $concurrency = (int) $this->config->get('concurrency'); |
|
179 | 179 | for ($i = 0; $i < $concurrency; $i++) { |
180 | 180 | $activeWorkerSet->add($this->forkWorker()); |
181 | 181 | } |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | |
213 | 213 | if (getmypid() === $this->masterPid) { |
214 | 214 | // master |
215 | - $this->log->info('forked worker. pid: ' . $worker->getPid()); |
|
215 | + $this->log->info('forked worker. pid: '.$worker->getPid()); |
|
216 | 216 | return $worker; |
217 | 217 | } else { |
218 | 218 | // worker |
219 | 219 | // @codeCoverageIgnoreStart |
220 | - $this->log->info('has forked. pid: ' . getmypid()); |
|
220 | + $this->log->info('has forked. pid: '.getmypid()); |
|
221 | 221 | |
222 | 222 | // for php5.3 |
223 | 223 | $receivedSignal = &$this->receivedSignal; |
224 | 224 | foreach ($this->signals as $sig) { |
225 | - $this->pcntl->signal($sig, function ($sig) use ($receivedSignal) { |
|
225 | + $this->pcntl->signal($sig, function($sig) use ($receivedSignal) { |
|
226 | 226 | $receivedSignal = $sig; |
227 | 227 | exit; |
228 | 228 | }, false); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $worker->setTaskQueue($this->queueFactory->createTaskQueue()); |
232 | 232 | $worker->setResultQueue($this->queueFactory->createResultQueue()); |
233 | 233 | |
234 | - register_shutdown_function(function () use ($worker, $receivedSignal) { |
|
234 | + register_shutdown_function(function() use ($worker, $receivedSignal) { |
|
235 | 235 | if ($worker->isFailedToEnqueueResult() && $receivedSignal === null) { |
236 | 236 | $worker->error(); |
237 | 237 | } |
@@ -267,14 +267,14 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function sendSignalToMaster($sig = SIGTERM) |
269 | 269 | { |
270 | - $this->log->info('----> sending signal to master. signal: ' . $sig); |
|
270 | + $this->log->info('----> sending signal to master. signal: '.$sig); |
|
271 | 271 | posix_kill($this->masterPid, $sig); |
272 | 272 | $this->log->info('<---- sent signal.'); |
273 | 273 | |
274 | 274 | $this->log->info('----> waiting for master shutdown.'); |
275 | 275 | $status = null; |
276 | 276 | $this->pcntl->waitpid($this->masterPid, $status); |
277 | - $this->log->info('<---- master shutdown. status: ' . $status); |
|
277 | + $this->log->info('<---- master shutdown. status: '.$status); |
|
278 | 278 | $this->masterPid = null; |
279 | 279 | } |
280 | 280 |