protected function signInWithLock(int $duration = null): Token
    {
        if ($this->store) {
            $factory = new Factory($this->store);
            $factory->setLogger($this->logger);
            $lock = $factory->createLock($this->user->getMpxUsername(), 10);

            // Blocking means this will throw an exception on failure.
            $lock->acquire(true);
        }

        try {
            // It's possible another thread has signed in for us, so check for a token first.
            $token = $this->tokenCachePool->getToken($this);
        } catch (TokenNotFoundException $e) {
            // We have the lock, and there's no token, so sign in.
            $token = $this->signIn($duration);
        }

        return $token;
    }
protected function signInWithLock(int $duration = null): Token
    {
        if ($this->store) {
            $factory = new Factory($this->store);
            $factory->setLogger($this->logger);
            $lock = $factory->createLock($this->user->getMpxUsername(), 10);

            // Blocking means this will throw an exception on failure.
            $lock->acquire(true);
        }

        try {
            // It's possible another thread has signed in for us, so check for a token first.
            $token = $this->tokenCachePool->getToken($this);
        } catch (TokenNotFoundException $e) {
            // We have the lock, and there's no token, so sign in.
            $token = $this->signIn($duration);
        }

        return $token;
    }
protected function signInWithLock ( int $ duration = null ) : Token { if ( $ this -> store ) { $ factory = new Factory ( $ this -> store ) ; $ factory -> setLogger ( $ this -> logger ) ; $ lock = $ factory -> createLock ( $ this -> user -> getMpxUsername ( ) , 10 ) ; // Blocking means this will throw an exception on failure. $ lock -> acquire ( true ) ; } try { // It's possible another thread has signed in for us, so check for a token first. $ token = $ this -> tokenCachePool -> getToken ( $ this ) ; } catch ( TokenNotFoundException $ e ) { // We have the lock, and there's no token, so sign in. $ token = $ this -> signIn ( $ duration ) ; } return $ token ; }
Sign in to mpx, with a lock to prevent sign-in stampedes.

@param int $duration (optional) The number of seconds that the sign-in token should be valid for.

@return Token
Sign in to mpx with a lock to prevent sign - in stampedes .