|
3 | 3 |
|
4 | 4 | @interface TOCFuture (TOCFutureExtra)
|
5 | 5 |
|
6 |
| -/// @abstract Returns a future that completes with the value returned by a function run via grand central dispatch. |
| 6 | +/*! |
| 7 | + * Returns a future that completes with the value returned by a function run via grand central dispatch. |
| 8 | + * |
| 9 | + * @param operation The operation to eventually evaluate. |
| 10 | + * |
| 11 | + * @param queue The gcd queue to dispatch the operation on. |
| 12 | + * |
| 13 | + * @result A future that completes once the operation has been completed, and contains the operation's result. |
| 14 | + */ |
7 | 15 | +(TOCFuture*) futureWithResultFromOperation:(id (^)(void))operation
|
8 | 16 | dispatchedOnQueue:(dispatch_queue_t)queue;
|
9 | 17 |
|
10 |
| -/// @abstract Returns a future that completes with the value returned by a function invoked on the given thread. |
11 |
| -/// @param operation The function to run. Must not be nil. |
12 |
| -/// @param thread The thread to invoke the function on. Must not be nil. |
| 18 | +/*! |
| 19 | + * Returns a future that completes with the value returned by a function run on a specified thread. |
| 20 | + * |
| 21 | + * @param operation The operation to eventually evaluate. |
| 22 | + * |
| 23 | + * @param thread The thread to perform the operation on. |
| 24 | + * |
| 25 | + * @result A future that completes once the operation has been completed, and contains the operation's result. |
| 26 | + */ |
13 | 27 | +(TOCFuture*) futureWithResultFromOperation:(id(^)(void))operation
|
14 | 28 | invokedOnThread:(NSThread*)thread;
|
15 | 29 |
|
16 |
| -/// @abstract Returns a future that completes after a given delay (mechanism unspecified [timer, grand central dispatch, whatever]). |
17 |
| -/// @param resultValue The result that the future will succeed with after the given delay. |
18 |
| -/// @param delay The number of seconds the future is incomplete for. |
19 |
| -/// Must not be negative or NaN (raises exception). |
20 |
| -/// A delay of 0 results in a future that's already completed. |
21 |
| -/// A delay of INFINITY results in a future that's never completed. |
22 |
| -+(TOCFuture*) futureWithResult:(id)resultValue |
23 |
| - afterDelay:(NSTimeInterval)delay; |
24 |
| - |
| 30 | +/*! |
| 31 | + * Returns a future that will contain the given result after the given delay, unless cancelled. |
| 32 | + * |
| 33 | + * @param resultValue The value the resulting future should complete with, after the delay has passed. |
| 34 | + * |
| 35 | + * @param delay The amount of time to wait, in seconds, before the resulting future completes. |
| 36 | + * Must not be negative or NaN (raises exception). |
| 37 | + * A delay of 0 results in a future that's already completed. |
| 38 | + * A delay of INFINITY result in an immortal future that never completes. |
| 39 | + * |
| 40 | + * @param unlessCancelledToken If this token is cancelled before the delay expires, the future immediately fails with the cancel token as its failure. |
| 41 | + * Any resources being used for the delay, such as NSTimers, will also be immediately cleaned up upon cancellation. |
| 42 | + * |
| 43 | + * @result A delayed future result, unless the delay is cancelled. |
| 44 | + */ |
25 | 45 | +(TOCFuture*) futureWithResult:(id)resultValue
|
26 | 46 | afterDelay:(NSTimeInterval)delay
|
27 | 47 | unless:(TOCCancelToken*)unlessCancelledToken;
|
28 | 48 |
|
| 49 | +/*! |
| 50 | + * Returns a future that will contain the given result after the given delay. |
| 51 | + * |
| 52 | + * @param resultValue The value the resulting future should complete with, after the delay has passed. |
| 53 | + * |
| 54 | + * @param delay The amount of time to wait, in seconds, before the resulting future completes. |
| 55 | + * Must not be negative or NaN (raises exception). |
| 56 | + * A delay of 0 results in a future that's already completed. |
| 57 | + * A delay of INFINITY result in an immortal future that never completes. |
| 58 | + * |
| 59 | + * @result A delayed future result. |
| 60 | + */ |
| 61 | ++(TOCFuture*) futureWithResult:(id)resultValue |
| 62 | + afterDelay:(NSTimeInterval)delay; |
| 63 | + |
29 | 64 | @end
|
0 commit comments