Skip to content

Conversation

@maxsky
Copy link
Contributor

@maxsky maxsky commented Dec 1, 2021

No description provided.

@driesvints
Copy link
Member

This definitely isn't correct. The return type should always be a boolean.

@maxsky
Copy link
Contributor Author

maxsky commented Dec 1, 2021

This definitely isn't correct. The return type should always be a boolean.

maybe return by $callback, source code same with 8.x

public function block($seconds, $callback = null)
{
    $starting = $this->currentTime();

    while (! $this->acquire()) {
        usleep(250 * 1000);

        if ($this->currentTime() - $seconds >= $starting) {
            throw new LockTimeoutException;
        }
    }

    if (is_callable($callback)) {
        try {
            return $callback();
        } finally {
            $this->release();
        }
    }

    return true;
}

@taylorotwell taylorotwell merged commit 5e56518 into laravel:6.x Dec 1, 2021
@GrahamCampbell GrahamCampbell changed the title Update lock return type [6.x] Update lock return type Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants