1
0
mirror of https://github.com/danog/amp.git synced 2025-01-21 21:01:16 +01:00
This commit is contained in:
Andrew Carter 2016-03-14 10:56:31 +00:00
parent 2843dbf1f3
commit 780d32bc6c

View File

@ -5,62 +5,111 @@ namespace Interop\Async\EventLoop;
interface EventLoopInterface
{
/**
* Start the event loop.
*
* @return void
*/
public function run(callable $onStart = null);
public function run();
/**
* Stop the event loop.
*
* @return void
*/
public function stop();
/**
* @return string
* Defer the execution of a callback.
*
* @param callable $callback The callback to defer.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function defer(callable $callback);
/**
* @return string
* Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
*
* @param callable $callback The callback to delay.
* @param float $time The amount of time, in seconds, to delay the execution for.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function delay(callable $callback, float $time);
/**
* @return string
* Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
*
* @param callable $callback The callback to repeat.
* @param float $interval The time interval, in seconds, to wait between executions.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function repeat(callable $callback, float $interval);
/**
* @return string
* Execute a callback when a stream resource becomes readable.
*
* @param resource $stream The stream to monitor.
* @param callable $callback The callback to execute.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function onReadable($stream, callable $callback);
/**
* @return string
* Execute a callback when a stream resource becomes writable.
*
* @param resource $stream The stream to monitor.
* @param callable $callback The callback to execute.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function onWritable($stream, callable $callback);
/**
* @return string
* Execute a callback when a signal is received.
*
* @param int $signo The signal number to monitor.
* @param callable $callback The callback to execute.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function onSignal(int $signo, callable $callback);
/**
* @return string
* Execute a callback when an error occurs.
*
* @param callable $callback The callback to execute.
*
* @return string An identifier that can be used to cancel, enable or disable the event.
*/
public function onError(callable $callback);
/**
* Enable an event.
*
* @param string $eventIdentifier The event identifier.
*
* @return void
*/
public function enable(string $watcherId);
public function enable(string $eventIdentifier);
/**
* Disable an event.
*
* @param string $eventIdentifier The event identifier.
*
* @return void
*/
public function disable(string $watcherId);
public function disable(string $eventIdentifier);
/**
* Cancel an event.
*
* @param string $eventIdentifier The event identifier.
*
* @return void
*/
public function cancel(string $watcherId);
public function cancel(string $eventIdentifier);
}