Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Update lock return type #39859

Merged
merged 1 commit into from
Dec 1, 2021
Merged

[6.x] Update lock return type #39859

merged 1 commit into from
Dec 1, 2021

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