| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | public function execute(string $name, callable $callback, int $timeout = 0) |
||
| 38 | { |
||
| 39 | $mutex = $this->mutexFactory->create($name); |
||
| 40 | |||
| 41 | if (!$mutex->acquire($timeout)) { |
||
| 42 | throw new RuntimeException("Unable to execute synchronized \"$name\"."); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** @var mixed $result */ |
||
| 46 | $result = $callback(); |
||
| 47 | $mutex->release(); |
||
| 48 | return $result; |
||
| 49 | } |
||
| 51 |