Initial Commit
This commit is contained in:
21
dependencies/amphp/sync/src/PrefixedKeyedSemaphore.php
vendored
Normal file
21
dependencies/amphp/sync/src/PrefixedKeyedSemaphore.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\Amp\Sync;
|
||||
|
||||
use WP_Ultimo\Dependencies\Amp\Promise;
|
||||
final class PrefixedKeyedSemaphore implements KeyedSemaphore
|
||||
{
|
||||
/** @var KeyedSemaphore */
|
||||
private $semaphore;
|
||||
/** @var string */
|
||||
private $prefix;
|
||||
public function __construct(KeyedSemaphore $semaphore, string $prefix)
|
||||
{
|
||||
$this->semaphore = $semaphore;
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
public function acquire(string $key) : Promise
|
||||
{
|
||||
return $this->semaphore->acquire($this->prefix . $key);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user