Add mutex

This commit is contained in:
Daniil Gentili 2024-06-26 22:39:03 +02:00
parent 561fec0a12
commit 40d16c372a

View File

@ -52,6 +52,7 @@ class Client
public function addSession(string $session, array $settings = []): API public function addSession(string $session, array $settings = []): API
{ {
$this->mutex ??= new LocalKeyedMutex;
$lock = $this->mutex->acquire($session); $lock = $this->mutex->acquire($session);
if (isset($this->instances[$session])) { if (isset($this->instances[$session])) {
throw new InvalidArgumentException('Session already exists'); throw new InvalidArgumentException('Session already exists');