File tree Expand file tree Collapse file tree 6 files changed +28
-23
lines changed Expand file tree Collapse file tree 6 files changed +28
-23
lines changed Original file line number Diff line number Diff line change 28
28
29
29
- name : Configure PHP
30
30
run : |
31
- install-php-extensions memcached sysvsem
32
31
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
33
32
php --version
34
33
37
36
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit ergebnis/phpunit-slow-test-detector --dev; fi
38
37
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev; fi
39
38
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* --dev; fi
39
+ composer remove --no-interaction --no-update ext-lzf ext-memcached ext-sysvsem --dev
40
40
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
41
41
42
42
- name : " Run tests (only for Phpunit)"
Original file line number Diff line number Diff line change 39
39
"symfony/polyfill-php80" : " ^1.28"
40
40
},
41
41
"require-dev" : {
42
+ "ext-igbinary" : " *" ,
43
+ "ext-lzf" : " *" ,
42
44
"ext-memcached" : " *" ,
43
45
"ext-pcntl" : " *" ,
44
46
"ext-pdo" : " *" ,
45
47
"ext-pdo_mysql" : " *" ,
46
48
"ext-pdo_sqlite" : " *" ,
49
+ "ext-redis" : " *" ,
47
50
"ext-sysvsem" : " *" ,
48
51
"eloquent/liberator" : " ^2.0 || ^3.0" ,
49
52
"ergebnis/composer-normalize" : " ^2.13" ,
62
65
"suggest" : {
63
66
"ext-igbinary" : " To use this library with PHP Redis igbinary serializer enabled." ,
64
67
"ext-lzf" : " To use this library with PHP Redis lzf compression enabled." ,
65
- "ext-pnctl " : " Enables locking with flock without busy waiting in CLI scripts." ,
68
+ "ext-pcntl " : " Enables locking with flock without busy waiting in CLI scripts." ,
66
69
"ext-redis" : " To use this library with the PHP Redis extension." ,
67
70
"ext-sysvsem" : " Enables locking using semaphores." ,
68
71
"predis/predis" : " To use this library with predis."
Original file line number Diff line number Diff line change 14
14
*
15
15
* You should not instantiate this class directly. Use
16
16
* {@link \Malkusch\Lock\Mutex\Mutex::check()}.
17
+ *
18
+ * @internal
17
19
*/
18
20
class DoubleCheckedLocking
19
21
{
Original file line number Diff line number Diff line change 13
13
*/
14
14
class Loop
15
15
{
16
- /**
17
- * Minimum time that we want to wait, between lock checks. In micro seconds.
18
- */
16
+ /** Minimum time that we want to wait, between lock checks. In micro seconds. */
19
17
private const MINIMUM_WAIT_US = 1e4 ; // 0.01 seconds
20
18
21
- /**
22
- * Maximum time that we want to wait, between lock checks. In micro seconds.
23
- */
19
+ /** Maximum time that we want to wait, between lock checks. In micro seconds. */
24
20
private const MAXIMUM_WAIT_US = 5e5 ; // 0.50 seconds
25
21
26
22
/** @var float The timeout in seconds */
Original file line number Diff line number Diff line change @@ -251,18 +251,20 @@ public static function provideExecutionIsSerializedWhenLockedCases(): iterable
251
251
return $ lock ->popsValue ();
252
252
}];
253
253
254
- yield 'semaphore ' => [static function () use ($ filename ): Mutex {
255
- $ semaphore = sem_get (ftok ($ filename , 'b ' ));
256
- self ::assertThat (
257
- $ semaphore ,
258
- self ::logicalOr (
259
- self ::isInstanceOf (\SysvSemaphore::class),
260
- new IsType (IsType::TYPE_RESOURCE )
261
- )
262
- );
263
-
264
- return new SemaphoreMutex ($ semaphore );
265
- }];
254
+ if (extension_loaded ('sysvsem ' )) {
255
+ yield 'semaphore ' => [static function () use ($ filename ): Mutex {
256
+ $ semaphore = sem_get (ftok ($ filename , 'b ' ));
257
+ self ::assertThat (
258
+ $ semaphore ,
259
+ self ::logicalOr (
260
+ self ::isInstanceOf (\SysvSemaphore::class),
261
+ new IsType (IsType::TYPE_RESOURCE )
262
+ )
263
+ );
264
+
265
+ return new SemaphoreMutex ($ semaphore );
266
+ }];
267
+ }
266
268
267
269
if (getenv ('MEMCACHE_HOST ' )) {
268
270
yield 'memcached ' => [static function ($ timeout ): Mutex {
Original file line number Diff line number Diff line change @@ -81,9 +81,11 @@ public static function provideMutexFactoriesCases(): iterable
81
81
return $ lock ->popsValue ();
82
82
}];
83
83
84
- yield 'SemaphoreMutex ' => [static function (): Mutex {
85
- return new SemaphoreMutex (sem_get (ftok (__FILE__ , 'a ' )));
86
- }];
84
+ if (extension_loaded ('sysvsem ' )) {
85
+ yield 'SemaphoreMutex ' => [static function (): Mutex {
86
+ return new SemaphoreMutex (sem_get (ftok (__FILE__ , 'a ' )));
87
+ }];
88
+ }
87
89
88
90
yield 'SpinlockMutex ' => [static function (): Mutex {
89
91
$ lock = new class ('test ' ) extends SpinlockMutex {
You can’t perform that action at this time.
0 commit comments