mirror of
https://github.com/danog/amp.git
synced 2024-12-11 17:09:40 +01:00
Removed inScope()
This commit is contained in:
parent
71fcb29126
commit
624060c67f
@ -39,7 +39,9 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function get()
|
public static function get()
|
||||||
{
|
{
|
||||||
self::inScope();
|
if (null === self::$driver) {
|
||||||
|
throw new \RuntimeException('Not within the scope of an event loop driver');
|
||||||
|
}
|
||||||
|
|
||||||
return self::$driver;
|
return self::$driver;
|
||||||
}
|
}
|
||||||
@ -51,9 +53,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function stop()
|
public static function stop()
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->stop();
|
||||||
|
|
||||||
self::$driver->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,9 +65,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function defer(callable $callback)
|
public static function defer(callable $callback)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->defer($callback);
|
||||||
|
|
||||||
return self::$driver->defer($callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,9 +78,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function delay(callable $callback, float $time)
|
public static function delay(callable $callback, float $time)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->delay($callback, $time);
|
||||||
|
|
||||||
return self::$driver->delay($callback, $time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,9 +91,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function repeat(callable $callback, float $interval)
|
public static function repeat(callable $callback, float $interval)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->repeat($callback, $interval);
|
||||||
|
|
||||||
return self::$driver->repeat($callback, $interval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,9 +104,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function onReadable($stream, callable $callback)
|
public static function onReadable($stream, callable $callback)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->onReadable($stream, $callback);
|
||||||
|
|
||||||
return self::$driver->onReadable($stream, $callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,9 +117,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function onWritable($stream, callable $callback)
|
public static function onWritable($stream, callable $callback)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->onWritable($stream, $callback);
|
||||||
|
|
||||||
return self::$driver->onWritable($stream, $callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,9 +130,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function onSignal(int $signo, callable $callback)
|
public static function onSignal(int $signo, callable $callback)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->onSignal($signo, $callback);
|
||||||
|
|
||||||
return self::$driver->onSignal($signo, $callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,9 +142,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function onError(callable $callback)
|
public static function onError(callable $callback)
|
||||||
{
|
{
|
||||||
self::inScope();
|
return self::get()->onError($callback);
|
||||||
|
|
||||||
return self::$driver->onError($callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,9 +154,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function enable(string $eventIdentifier)
|
public static function enable(string $eventIdentifier)
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->enable($eventIdentifier);
|
||||||
|
|
||||||
self::$driver->enable($eventIdentifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,9 +166,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function disable(string $eventIdentifier)
|
public static function disable(string $eventIdentifier)
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->disable($eventIdentifier);
|
||||||
|
|
||||||
self::$driver->disable($eventIdentifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,9 +178,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function cancel(string $eventIdentifier)
|
public static function cancel(string $eventIdentifier)
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->cancel($eventIdentifier);
|
||||||
|
|
||||||
self::$driver->cancel($eventIdentifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -212,9 +192,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function reference(string $eventIdentifier)
|
public static function reference(string $eventIdentifier)
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->reference($eventIdentifier);
|
||||||
|
|
||||||
self::$driver->reference($eventIdentifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,21 +207,7 @@ final class EventLoop
|
|||||||
*/
|
*/
|
||||||
public static function unreference(string $eventIdentifier)
|
public static function unreference(string $eventIdentifier)
|
||||||
{
|
{
|
||||||
self::inScope();
|
self::get()->unreference($eventIdentifier);
|
||||||
|
|
||||||
self::$driver->unreference($eventIdentifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that the event loop is currently within the scope of a driver.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function inScope()
|
|
||||||
{
|
|
||||||
if (null === self::$driver) {
|
|
||||||
throw new \RuntimeException('Not within the scope of an event loop driver');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user