mirror of
https://github.com/danog/amp.git
synced 2025-01-22 13:21:16 +01:00
Mark loop classes final
This commit is contained in:
parent
8ee7d61452
commit
1db52920ab
@ -18,8 +18,8 @@ use function Amp\Promise\rethrow;
|
|||||||
abstract class Driver implements \FiberScheduler
|
abstract class Driver implements \FiberScheduler
|
||||||
{
|
{
|
||||||
// Don't use 1e3 / 1e6, they result in a float instead of int
|
// Don't use 1e3 / 1e6, they result in a float instead of int
|
||||||
const MILLISEC_PER_SEC = 1000;
|
protected const MILLISEC_PER_SEC = 1000;
|
||||||
const MICROSEC_PER_SEC = 1000000;
|
protected const MICROSEC_PER_SEC = 1000000;
|
||||||
|
|
||||||
/** @var string Next watcher ID. */
|
/** @var string Next watcher ID. */
|
||||||
private string $nextId = "a";
|
private string $nextId = "a";
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Amp\Loop;
|
namespace Amp\Loop;
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
class DriverFactory
|
final class DriverFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a new loop instance and chooses the best available driver.
|
* Creates a new loop instance and chooses the best available driver.
|
||||||
|
@ -8,7 +8,7 @@ use React\Promise\PromiseInterface as ReactPromise;
|
|||||||
use function Amp\Internal\getCurrentTime;
|
use function Amp\Internal\getCurrentTime;
|
||||||
use function Amp\Promise\rethrow;
|
use function Amp\Promise\rethrow;
|
||||||
|
|
||||||
class EvDriver extends Driver
|
final class EvDriver extends Driver
|
||||||
{
|
{
|
||||||
/** @var \EvSignal[]|null */
|
/** @var \EvSignal[]|null */
|
||||||
private static ?array $activeSignals = null;
|
private static ?array $activeSignals = null;
|
||||||
@ -24,7 +24,6 @@ class EvDriver extends Driver
|
|||||||
private array $events = [];
|
private array $events = [];
|
||||||
|
|
||||||
private \Closure $ioCallback;
|
private \Closure $ioCallback;
|
||||||
/** @var callable */
|
|
||||||
|
|
||||||
private \Closure $timerCallback;
|
private \Closure $timerCallback;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use React\Promise\PromiseInterface as ReactPromise;
|
|||||||
use function Amp\Internal\getCurrentTime;
|
use function Amp\Internal\getCurrentTime;
|
||||||
use function Amp\Promise\rethrow;
|
use function Amp\Promise\rethrow;
|
||||||
|
|
||||||
class EventDriver extends Driver
|
final class EventDriver extends Driver
|
||||||
{
|
{
|
||||||
/** @var \Event[]|null */
|
/** @var \Event[]|null */
|
||||||
private static ?array $activeSignals = null;
|
private static ?array $activeSignals = null;
|
||||||
|
@ -7,10 +7,10 @@ namespace Amp\Loop;
|
|||||||
*
|
*
|
||||||
* An invalid watcher identifier is any identifier that is not yet emitted by the driver or cancelled by the user.
|
* An invalid watcher identifier is any identifier that is not yet emitted by the driver or cancelled by the user.
|
||||||
*/
|
*/
|
||||||
class InvalidWatcherError extends \Error
|
final class InvalidWatcherError extends \Error
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $watcherId;
|
private string $watcherId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $watcherId The watcher identifier.
|
* @param string $watcherId The watcher identifier.
|
||||||
@ -25,7 +25,7 @@ class InvalidWatcherError extends \Error
|
|||||||
/**
|
/**
|
||||||
* @return string The watcher identifier.
|
* @return string The watcher identifier.
|
||||||
*/
|
*/
|
||||||
public function getWatcherId()
|
public function getWatcherId(): string
|
||||||
{
|
{
|
||||||
return $this->watcherId;
|
return $this->watcherId;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use React\Promise\PromiseInterface as ReactPromise;
|
|||||||
use function Amp\Internal\getCurrentTime;
|
use function Amp\Internal\getCurrentTime;
|
||||||
use function Amp\Promise\rethrow;
|
use function Amp\Promise\rethrow;
|
||||||
|
|
||||||
class NativeDriver extends Driver
|
final class NativeDriver extends Driver
|
||||||
{
|
{
|
||||||
/** @var resource[] */
|
/** @var resource[] */
|
||||||
private array $readStreams = [];
|
private array $readStreams = [];
|
||||||
|
@ -25,11 +25,6 @@ final class TracingDriver extends Driver
|
|||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createControl(): DriverControl
|
|
||||||
{
|
|
||||||
return $this->driver->createControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$this->driver->run();
|
$this->driver->run();
|
||||||
|
@ -7,6 +7,6 @@ namespace Amp\Loop;
|
|||||||
*
|
*
|
||||||
* This might happen if ext-pcntl is missing and the loop driver doesn't support another way to dispatch signals.
|
* This might happen if ext-pcntl is missing and the loop driver doesn't support another way to dispatch signals.
|
||||||
*/
|
*/
|
||||||
class UnsupportedFeatureException extends \Exception
|
final class UnsupportedFeatureException extends \Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use Amp\Promise;
|
|||||||
use React\Promise\PromiseInterface as ReactPromise;
|
use React\Promise\PromiseInterface as ReactPromise;
|
||||||
use function Amp\Promise\rethrow;
|
use function Amp\Promise\rethrow;
|
||||||
|
|
||||||
class UvDriver extends Driver
|
final class UvDriver extends Driver
|
||||||
{
|
{
|
||||||
/** @var resource|\UVLoop A uv_loop resource created with uv_loop_new() */
|
/** @var resource|\UVLoop A uv_loop resource created with uv_loop_new() */
|
||||||
private $handle;
|
private $handle;
|
||||||
|
@ -9,18 +9,18 @@ use Amp\Struct;
|
|||||||
*
|
*
|
||||||
* @psalm-suppress MissingConstructor
|
* @psalm-suppress MissingConstructor
|
||||||
*/
|
*/
|
||||||
class Watcher
|
final class Watcher
|
||||||
{
|
{
|
||||||
use Struct;
|
use Struct;
|
||||||
|
|
||||||
const IO = 0b00000011;
|
public const IO = 0b00000011;
|
||||||
const READABLE = 0b00000001;
|
public const READABLE = 0b00000001;
|
||||||
const WRITABLE = 0b00000010;
|
public const WRITABLE = 0b00000010;
|
||||||
const DEFER = 0b00000100;
|
public const DEFER = 0b00000100;
|
||||||
const TIMER = 0b00011000;
|
public const TIMER = 0b00011000;
|
||||||
const DELAY = 0b00001000;
|
public const DELAY = 0b00001000;
|
||||||
const REPEAT = 0b00010000;
|
public const REPEAT = 0b00010000;
|
||||||
const SIGNAL = 0b00100000;
|
public const SIGNAL = 0b00100000;
|
||||||
|
|
||||||
public int $type;
|
public int $type;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user