Skip to content

Commit

Permalink
[10.x] Siesta (laravel#46904)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update src/Illuminate/Support/Siesta.php

Co-authored-by: Nuno Maduro <[email protected]>

* Update src/Illuminate/Support/Siesta.php

Co-authored-by: Nuno Maduro <[email protected]>

* Update src/Illuminate/Support/Siesta.php

Co-authored-by: Nuno Maduro <[email protected]>

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* formatting and rename to sleep

---------

Co-authored-by: Nuno Maduro <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored May 3, 2023
1 parent 6e8b883 commit c164078
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 5 deletions.
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);
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

0 comments on commit c164078

Please sign in to comment.