1<?php
2namespace GuzzleHttp\Ring\Future;
3
4use React\Promise\PromiseInterface;
5use React\Promise\PromisorInterface;
6
7/**
8 * Represents the result of a computation that may not have completed yet.
9 *
10 * You can use the future in a blocking manner using the wait() function, or
11 * you can use a promise from the future to receive the result when the future
12 * has been resolved.
13 *
14 * When the future is dereferenced using wait(), the result of the computation
15 * is cached and returned for subsequent calls to wait(). If the result of the
16 * computation has not yet completed when wait() is called, the call to wait()
17 * will block until the future has completed.
18 */
19interface FutureInterface extends PromiseInterface, PromisorInterface
20{
21    /**
22     * Returns the result of the future either from cache or by blocking until
23     * it is complete.
24     *
25     * This method must block until the future has a result or is cancelled.
26     * Throwing an exception in the wait() method will mark the future as
27     * realized and will throw the exception each time wait() is called.
28     * Throwing an instance of GuzzleHttp\Ring\CancelledException will mark
29     * the future as realized, will not throw immediately, but will throw the
30     * exception if the future's wait() method is called again.
31     *
32     * @return mixed
33     */
34    public function wait();
35
36    /**
37     * Cancels the future, if possible.
38     */
39    public function cancel();
40}
41