-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,943 additions
and
570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psl\IO\Exception; | ||
|
||
final class TimeoutException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psl\IO\Internal; | ||
|
||
use function microtime; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
final class OptionalIncrementalTimeout | ||
{ | ||
private ?float $end; | ||
/** | ||
* @var (callable(): ?int) | ||
*/ | ||
private $handler; | ||
|
||
/** | ||
* @param (callable(): ?int) $handler | ||
*/ | ||
public function __construct(?int $timeout_ms, callable $handler) | ||
{ | ||
$this->handler = $handler; | ||
if ($timeout_ms === null) { | ||
$this->end = null; | ||
return; | ||
} | ||
|
||
$this->end = microtime(true) + (float) $timeout_ms; | ||
} | ||
|
||
public function getRemaining(): ?int | ||
{ | ||
if ($this->end === null) { | ||
return null; | ||
} | ||
|
||
$remaining = $this->end - microtime(true); | ||
if ($remaining <= 0) { | ||
$th = $this->handler; | ||
return $th(); | ||
} | ||
|
||
return $remaining < 1.0 ? 1 : (int) $remaining; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.