@@ -127,8 +127,8 @@ if ($newBalance === false) {
127
127
128
128
### Extracting code result after lock release exception
129
129
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
132
132
problem, but the synchronized code block will be already executed at this point.
133
133
In order to read the code result (or an exception thrown there),
134
134
` LockReleaseException ` provides methods to extract it.
@@ -164,7 +164,6 @@ Because the [`Malkusch\Lock\Mutex\Mutex`](#mutex) class is an abstract class,
164
164
you can choose from one of the provided implementations or create/extend your
165
165
own implementation.
166
166
167
- - [ ` CASMutex ` ] ( #casmutex )
168
167
- [ ` FlockMutex ` ] ( #flockmutex )
169
168
- [ ` MemcachedMutex ` ] ( #memcachedmutex )
170
169
- [ ` PHPRedisMutex ` ] ( #phpredismutex )
@@ -174,30 +173,6 @@ own implementation.
174
173
- [ ` MySQLMutex ` ] ( #mysqlmutex )
175
174
- [ ` PgAdvisoryLockMutex ` ] ( #pgadvisorylockmutex )
176
175
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
-
201
176
#### FlockMutex
202
177
203
178
The ** FlockMutex** is a lock implementation based on
@@ -406,7 +381,5 @@ This project is free and is licensed under the MIT.
406
381
[ 7 ] : https://github.com/php-lock/lock/blob/35526aee28/src/mutex/Mutex.php#L60
407
382
[ 8 ] : https://github.com/php-lock/lock/blob/35526aee28/src/util/DoubleCheckedLocking.php#L63
408
383
[ 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