mirror of
https://github.com/danog/parallel.git
synced 2024-12-13 17:47:32 +01:00
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
namespace Icicle\Concurrent;
|
|
|
|
/**
|
|
* Interface for all types of execution contexts.
|
|
*/
|
|
interface ContextInterface
|
|
{
|
|
/**
|
|
* Checks if the context is running.
|
|
*
|
|
* @return bool True if the context is running, otherwise false.
|
|
*/
|
|
public function isRunning();
|
|
|
|
/**
|
|
* Acquires a lock on the context.
|
|
*/
|
|
public function lock();
|
|
|
|
/**
|
|
* Unlocks the context.
|
|
*/
|
|
public function unlock();
|
|
|
|
/**
|
|
* Invokes a function while maintaining a lock for the calling context.
|
|
*
|
|
* @param callable $callback The function to invoke.
|
|
*
|
|
* @return mixed The value returned by the callback.
|
|
*/
|
|
public function synchronized(callable $callback);
|
|
|
|
/**
|
|
* Starts the context execution.
|
|
*/
|
|
public function start();
|
|
|
|
/**
|
|
* Stops context execution.
|
|
*/
|
|
public function stop();
|
|
|
|
/**
|
|
* Immediately kills the context without invoking any handlers.
|
|
*/
|
|
public function kill();
|
|
|
|
/**
|
|
* Gets a promise that resolves when the context ends and joins with the
|
|
* parent context.
|
|
*
|
|
* @return PromiseInterface Promise that is resolved when the context finishes.
|
|
*/
|
|
public function join();
|
|
|
|
/**
|
|
* Executes the context's main code.
|
|
*/
|
|
public function run();
|
|
}
|