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

[10.x] Siesta #46904

Merged
merged 25 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/Cache/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Contracts\Cache\Lock as LockContract;
use Illuminate\Contracts\Cache\LockTimeoutException;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Sleep;
use Illuminate\Support\Str;

abstract class Lock implements LockContract
Expand Down Expand Up @@ -114,7 +115,7 @@ public function block($seconds, $callback = null)
$starting = $this->currentTime();

while (! $this->acquire()) {
usleep($this->sleepMilliseconds * 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the complexity of the Siest class, I would rather not introduce it into the existing src code, as is very risky and it could potentially disrupt the current behavior, even if it appears otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at a bare minimum we want it used in the retry helper. After that, in order of what I would want to optionally see:

  • Timebox
  • Cache stuff

Sleep::usleep($this->sleepMilliseconds * 1000);

if ($this->currentTime() - $seconds >= $starting) {
throw new LockTimeoutException;
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\ParallelTesting;
use Illuminate\Support\Sleep;
use Illuminate\Support\Str;
use Illuminate\View\Component;
use Mockery;
Expand Down Expand Up @@ -245,6 +246,7 @@ protected function tearDown(): void
Component::forgetFactory();
Queue::createPayloadUsing(null);
HandleExceptions::forgetApp();
Sleep::fake(false);

if ($this->callbackException) {
throw $this->callbackException;
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Redis/Limiters/ConcurrencyLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Redis\Limiters;

use Illuminate\Contracts\Redis\LimiterTimeoutException;
use Illuminate\Support\Sleep;
use Illuminate\Support\Str;
use Throwable;

Expand Down Expand Up @@ -75,7 +76,7 @@ public function block($timeout, $callback = null, $sleep = 250)
throw new LimiterTimeoutException;
}

usleep($sleep * 1000);
Sleep::usleep($sleep * 1000);
}

if (is_callable($callback)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Redis/Limiters/DurationLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Redis\Limiters;

use Illuminate\Contracts\Redis\LimiterTimeoutException;
use Illuminate\Support\Sleep;

class DurationLimiter
{
Expand Down Expand Up @@ -84,7 +85,7 @@ public function block($timeout, $callback = null, $sleep = 750)
throw new LimiterTimeoutException;
}

usleep($sleep * 1000);
Sleep::usleep($sleep * 1000);
}

if (is_callable($callback)) {
Expand Down
Loading