44
55namespace malkusch \lock \mutex ;
66
7+ use malkusch \lock \exception \ExecutionOutsideLockException ;
8+ use malkusch \lock \exception \LockAcquireException ;
9+ use malkusch \lock \exception \LockReleaseException ;
710use malkusch \lock \util \DoubleCheckedLocking ;
811
912/**
@@ -27,13 +30,10 @@ abstract class Mutex
2730 *
2831 * @return T the return value of the execution callback
2932 *
30- * @throws \Exception the execution callback threw an exception
31- * @throws \malkusch\lock\exception\LockAcquireException the mutex could not
32- * be acquired, no further side effects
33- * @throws \malkusch\lock\exception\LockReleaseException the mutex could not
34- * be released, the code was already executed
35- * @throws \malkusch\lock\exception\ExecutionOutsideLockException some code
36- * has been executed outside of the lock
33+ * @throws \Exception the execution callback threw an exception
34+ * @throws LockAcquireException the mutex could not be acquired, no further side effects
35+ * @throws LockReleaseException the mutex could not be released, the code was already executed
36+ * @throws ExecutionOutsideLockException some code has been executed outside of the lock
3737 */
3838 abstract public function synchronized (callable $ code );
3939
@@ -45,19 +45,17 @@ abstract public function synchronized(callable $code);
4545 *
4646 * Example:
4747 * <code>
48- * $result = $mutex->check(function () use ($bankAccount, $amount) {
48+ * $result = $mutex->check(static function () use ($bankAccount, $amount) {
4949 * return $bankAccount->getBalance() >= $amount;
50- * })->then(function () use ($bankAccount, $amount) {
50+ * })->then(static function () use ($bankAccount, $amount) {
5151 * return $bankAccount->withdraw($amount);
5252 * });
5353 * </code>
5454 *
55- * @param callable(): bool $check callback that decides if the lock should be
56- * acquired and if the synchronized callback should be executed after
57- * acquiring the lock
55+ * @param callable(): bool $check callback that decides if the lock should be acquired and if the synchronized
56+ * callback should be executed after acquiring the lock
5857 *
59- * @return \malkusch\lock\util\DoubleCheckedLocking the double-checked
60- * locking pattern
58+ * @return DoubleCheckedLocking the double-checked locking pattern
6159 */
6260 public function check (callable $ check ): DoubleCheckedLocking
6361 {
0 commit comments