mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 11:54:42 +01:00
Add mutex
This commit is contained in:
parent
40d16c372a
commit
083c933ad3
@ -48,12 +48,12 @@ class Client
|
||||
);
|
||||
}
|
||||
|
||||
private LocalKeyedMutex $mutex;
|
||||
private static LocalKeyedMutex $mutex;
|
||||
|
||||
public function addSession(string $session, array $settings = []): API
|
||||
{
|
||||
$this->mutex ??= new LocalKeyedMutex;
|
||||
$lock = $this->mutex->acquire($session);
|
||||
self::$mutex ??= new LocalKeyedMutex;
|
||||
$lock = self::$mutex->acquire($session);
|
||||
if (isset($this->instances[$session])) {
|
||||
throw new InvalidArgumentException('Session already exists');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user