@@ -127,8 +127,8 @@ if ($newBalance === false) {
127127
128128### Extracting code result after lock release exception
129129
130- Mutex implementations based on [ ` Malkush\Lock\Mutex\LockMutex ` ] [ 12 ] will throw
131- [ ` Malkusch\Lock\Exception\LockReleaseException ` ] [ 13 ] in case of lock release
130+ Mutex implementations based on [ ` Malkush\Lock\Mutex\LockMutex ` ] [ 10 ] will throw
131+ [ ` Malkusch\Lock\Exception\LockReleaseException ` ] [ 11 ] in case of lock release
132132problem, but the synchronized code block will be already executed at this point.
133133In order to read the code result (or an exception thrown there),
134134` LockReleaseException ` provides methods to extract it.
@@ -164,7 +164,6 @@ Because the [`Malkusch\Lock\Mutex\Mutex`](#mutex) class is an abstract class,
164164you can choose from one of the provided implementations or create/extend your
165165own implementation.
166166
167- - [ ` CASMutex ` ] ( #casmutex )
168167- [ ` FlockMutex ` ] ( #flockmutex )
169168- [ ` MemcachedMutex ` ] ( #memcachedmutex )
170169- [ ` PHPRedisMutex ` ] ( #phpredismutex )
@@ -174,30 +173,6 @@ own implementation.
174173- [ ` MySQLMutex ` ] ( #mysqlmutex )
175174- [ ` PgAdvisoryLockMutex ` ] ( #pgadvisorylockmutex )
176175
177- #### CASMutex
178-
179- The ** CASMutex** has to be used with a [ Compare-and-swap] [ 10 ] operation. This
180- mutex is lock free. It will repeat executing the code until the CAS operation
181- was successful. The code should therefore notify the mutex by calling
182- [ ` Malkusch\Lock\Mutex\CASMutex::notify() ` ] [ 11 ] .
183-
184- As the mutex keeps executing the critical code, it must not have any side
185- effects as long as the CAS operation was not successful.
186-
187- Example:
188-
189- ``` php
190- $mutex = new CASMutex();
191- $mutex->synchronized(function () use ($memcached, $mutex, $amount): void {
192- $balance = $memcached->get('balance', null, $casToken);
193- $balance -= $amount;
194- if (!$memcached->cas($casToken, 'balance', $balance)) {
195- return;
196- }
197- $mutex->notify();
198- });
199- ```
200-
201176#### FlockMutex
202177
203178The ** FlockMutex** is a lock implementation based on
@@ -406,7 +381,5 @@ This project is free and is licensed under the MIT.
406381[ 7 ] : https://github.com/php-lock/lock/blob/35526aee28/src/mutex/Mutex.php#L60
407382[ 8 ] : https://github.com/php-lock/lock/blob/35526aee28/src/util/DoubleCheckedLocking.php#L63
408383[ 9 ] : https://en.wikipedia.org/wiki/Double-checked_locking
409- [ 10 ] : https://en.wikipedia.org/wiki/Compare-and-swap
410- [ 11 ] : https://github.com/php-lock/lock/blob/35526aee28/src/mutex/CASMutex.php#L42
411- [ 12 ] : https://github.com/php-lock/lock/blob/35526aee28/src/mutex/LockMutex.php
412- [ 13 ] : https://github.com/php-lock/lock/blob/35526aee28/src/exception/LockReleaseException.php
384+ [ 10 ] : https://github.com/php-lock/lock/blob/35526aee28/src/mutex/LockMutex.php
385+ [ 11 ] : https://github.com/php-lock/lock/blob/35526aee28/src/exception/LockReleaseException.php
0 commit comments