PluginProbe
DecaLog / 4.4.0
DecaLog v4.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / includes / libraries / lock / exception / ExecutionOutsideLockException.php

ExecutionOutsideLockException.php in DecaLog 4.4.0, at includes/libraries/lock/exception/ExecutionOutsideLockException.php

43 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace malkusch\lock\exception;
6
7 /**
8 * Execution outside lock exception.
9 *
10 * This exception should be thrown when for example the lock is released or the
11 * lock times out before the critical code has finished execution. This is a
12 * serious exception. Side effects might have happened while the critical code
13 * was executed outside of the lock which should not be trusted to be valid.
14 *
15 * Should only be used in contexts where the is being released.
16 *
17 * @see \malkusch\lock\mutex\SpinlockMutex::unlock()
18 *
19 * @author Petr Levtonov <petr@levtonov.com>
20 * @license WTFPL
21 */
22 class ExecutionOutsideLockException extends LockReleaseException
23 {
24 /**
25 * Creates a new instance of the ExecutionOutsideLockException class.
26 *
27 * @param float $elapsedTime Total elapsed time of the synchronized code
28 * callback execution.
29 * @param int $timeout The lock timeout in seconds.
30 * @return self Execution outside lock exception.
31 */
32 public static function create(float $elapsedTime, int $timeout): self
33 {
34 return new self(\sprintf(
35 'The code executed for %.2F seconds. But the timeout is %d ' .
36 'seconds. The last %.2F seconds were executed outside of the lock.',
37 $elapsedTime,
38 $timeout,
39 $elapsedTime - $timeout
40 ));
41 }
42 }
43