| Conditions | 2 |
| Paths | 2 |
| Total Lines | 9 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function execute(string $name, callable $callback, int $timeout = 0) |
||
| 17 | { |
||
| 18 | $mutex = $this->mutexFactory->create($name); |
||
| 19 | if (!$mutex->acquire($timeout)) { |
||
| 20 | throw new \RuntimeException("Unable to execute synchronized \"$name\"."); |
||
| 21 | } |
||
| 22 | $result = $callback(); |
||
| 23 | $mutex->release(); |
||
| 24 | return $result; |
||
| 25 | } |
||
| 27 |