From 3a30fa1d4ca5a36fc1efae17977f934bcc5eb6de Mon Sep 17 00:00:00 2001 From: coderstephen Date: Fri, 10 Jul 2015 02:22:04 -0500 Subject: [PATCH] Context interface now synchronizes synchronously and joins asynchronously --- src/Context.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Context.php b/src/Context.php index 377b834..e974f46 100644 --- a/src/Context.php +++ b/src/Context.php @@ -14,28 +14,19 @@ interface Context public function isRunning(); /** - * Acquires a lock on the context asynchronously. - * - * @return PromiseInterface Promise that is resolved when the lock is acquired. + * Acquires a lock on the context. */ public function lock(); /** * Unlocks the context. - * - * @return bool True if successful, otherwise false. */ public function unlock(); /** * Executes a callback with write access to the context data. - * - * The callback is executed asynchronously in the future when other contexts - * are no longer synchronizing. - * - * @return PromiseInterface Promise that is resolved when the synchronization completes. */ - public function synchronize(callable $callback); + public function synchronized(callable $callback); /** * Starts the context execution. @@ -43,7 +34,20 @@ interface Context public function start(); /** - * Blocks the caller's execution until the referenced context finishes. + * 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();