BFTask Class Reference
| Inherits from | NSObject |
| Declared in | BFTask.h |
Overview
The consumer view of a Task. A BFTask has methods to inspect the state of the task, and to add continuations to be run once the task is complete.
Tasks
-
+ taskWithResult: -
+ taskWithError: -
+ taskWithException: -
+ cancelledTask -
+ taskForCompletionOfAllTasks: -
+ taskWithDelay: -
+ taskFromExecutor:withBlock: -
resultproperty -
errorproperty -
exceptionproperty -
cancelledproperty -
completedproperty -
– continueWithBlock: -
– continueWithExecutor:withBlock: -
– continueWithSuccessBlock: -
– continueWithExecutor:withSuccessBlock: -
– waitUntilFinished
Properties
cancelled
Whether this task has been cancelled.
@property (nonatomic, assign, readonly, getter=isCancelled) BOOL cancelledDiscussion
Whether this task has been cancelled.
Declared In
BFTask.hcompleted
Whether this task has completed.
@property (nonatomic, assign, readonly, getter=isCompleted) BOOL completedDiscussion
Whether this task has completed.
Declared In
BFTask.herror
The error of a failed task.
@property (nonatomic, strong, readonly) NSError *errorDiscussion
The error of a failed task.
Declared In
BFTask.hClass Methods
cancelledTask
Creates a task that is already cancelled.
+ (instancetype)cancelledTaskDiscussion
Creates a task that is already cancelled.
Declared In
BFTask.htaskForCompletionOfAllTasks:
Returns a task that will be completed (with result == nil) once all of the input tasks have completed.
+ (instancetype)taskForCompletionOfAllTasks:(id)tasksParameters
- tasks
An
NSArrayof the tasks to use as an input.
Discussion
Returns a task that will be completed (with result == nil) once all of the input tasks have completed.
Declared In
BFTask.htaskFromExecutor:withBlock:
Returns a task that will be completed after the given block completes with the specified executor.
+ (instancetype)taskFromExecutor:(id)executor withBlock:(id)blockParameters
- executor
A BFExecutor responsible for determining how the continuation block will be run.
- block
The block to immediately schedule to run with the given executor.
Return Value
A task that will be completed after block has run. If block returns a BFTask, then the task returned from this method will not be completed until that task is completed.
Discussion
Returns a task that will be completed after the given block completes with the specified executor.
Declared In
BFTask.htaskWithDelay:
Returns a task that will be completed a certain amount of time in the future.
+ (instancetype)taskWithDelay:(id)millisParameters
- millis
The approximate number of milliseconds to wait before the task will be finished (with result == nil).
Discussion
Returns a task that will be completed a certain amount of time in the future.
Declared In
BFTask.htaskWithError:
Creates a task that is already completed with the given error.
+ (instancetype)taskWithError:(id)errorParameters
- error
The error for the task.
Discussion
Creates a task that is already completed with the given error.
Declared In
BFTask.hInstance Methods
continueWithBlock:
Enqueues the given block to be run once this task is complete. This method uses a default execution strategy. The block will be run on the thread where the previous task completes, unless the the stack depth is too deep, in which case it will be run on a dispatch queue with default priority.
- (instancetype)continueWithBlock:(id)blockParameters
- block
The block to be run once this task is complete.
Return Value
A task that will be completed after block has run. If block returns a BFTask, then the task returned from this method will not be completed until that task is completed.
Discussion
Enqueues the given block to be run once this task is complete. This method uses a default execution strategy. The block will be run on the thread where the previous task completes, unless the the stack depth is too deep, in which case it will be run on a dispatch queue with default priority.
Declared In
BFTask.hcontinueWithExecutor:withBlock:
Enqueues the given block to be run once this task is complete.
- (instancetype)continueWithExecutor:(id)executor withBlock:(id)blockParameters
- executor
A BFExecutor responsible for determining how the continuation block will be run.
- block
The block to be run once this task is complete.
Return Value
A task that will be completed after block has run. If block returns a BFTask, then the task returned from this method will not be completed until that task is completed.
Discussion
Enqueues the given block to be run once this task is complete.
Declared In
BFTask.hcontinueWithExecutor:withSuccessBlock:
Identical to continueWithExecutor:withBlock:, except that the block is only run if this task did not produce a cancellation, error, or exception. If it did, then the failure will be propagated to the returned task.
- (instancetype)continueWithExecutor:(id)executor withSuccessBlock:(id)blockParameters
- executor
A BFExecutor responsible for determining how the continuation block will be run.
- block
The block to be run once this task is complete.
Return Value
A task that will be completed after block has run. If block returns a BFTask, then the task returned from this method will not be completed until that task is completed.
Discussion
Identical to continueWithExecutor:withBlock:, except that the block is only run if this task did not produce a cancellation, error, or exception. If it did, then the failure will be propagated to the returned task.
Declared In
BFTask.hcontinueWithSuccessBlock:
Identical to continueWithBlock:, except that the block is only run if this task did not produce a cancellation, error, or exception. If it did, then the failure will be propagated to the returned task.
- (instancetype)continueWithSuccessBlock:(id)blockParameters
- block
The block to be run once this task is complete.
Return Value
A task that will be completed after block has run. If block returns a BFTask, then the task returned from this method will not be completed until that task is completed.
Discussion
Identical to continueWithBlock:, except that the block is only run if this task did not produce a cancellation, error, or exception. If it did, then the failure will be propagated to the returned task.
Declared In
BFTask.hwaitUntilFinished
Waits until this operation is completed. This method is inefficient and consumes a thread resource while it’s running. It should be avoided. This method logs a warning message if it is used on the main thread.
- (void)waitUntilFinishedDiscussion
Waits until this operation is completed. This method is inefficient and consumes a thread resource while it’s running. It should be avoided. This method logs a warning message if it is used on the main thread.
Declared In
BFTask.h