| Total Complexity | 4 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait RetryAcquireTrait |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var int Number of milliseconds between each try until specified timeout times out. |
||
| 16 | * By default, it is 50 milliseconds - it means that we may try to acquire lock up to 20 times per |
||
| 17 | * second. |
||
| 18 | */ |
||
| 19 | private int $retryDelay = 50; |
||
| 20 | |||
| 21 | 2 | public function withRetryDelay(int $retryDelay): self |
|
| 22 | { |
||
| 23 | 2 | $new = clone $this; |
|
| 24 | 2 | $new->retryDelay = $retryDelay; |
|
| 25 | 2 | return $new; |
|
| 26 | } |
||
| 27 | |||
| 28 | 2 | private function retryAcquire(int $timeout, Closure $callback): bool |
|
| 39 | } |
||
| 40 | } |
||
| 41 |