commit | author | age
|
bad748
|
1 |
/* |
W |
2 |
* Copyright (c) 2014, Facebook, Inc. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the BSD-style license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
7 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
8 |
* |
|
9 |
*/ |
|
10 |
|
|
11 |
#import <Foundation/Foundation.h> |
|
12 |
|
|
13 |
NS_ASSUME_NONNULL_BEGIN |
|
14 |
|
|
15 |
/*! |
|
16 |
An object that can run a given block. |
|
17 |
*/ |
|
18 |
@interface BFExecutor : NSObject |
|
19 |
|
|
20 |
/*! |
|
21 |
Returns a default executor, which runs continuations immediately until the call stack gets too |
|
22 |
deep, then dispatches to a new GCD queue. |
|
23 |
*/ |
|
24 |
+ (instancetype)defaultExecutor; |
|
25 |
|
|
26 |
/*! |
|
27 |
Returns an executor that runs continuations on the thread where the previous task was completed. |
|
28 |
*/ |
|
29 |
+ (instancetype)immediateExecutor; |
|
30 |
|
|
31 |
/*! |
|
32 |
Returns an executor that runs continuations on the main thread. |
|
33 |
*/ |
|
34 |
+ (instancetype)mainThreadExecutor; |
|
35 |
|
|
36 |
/*! |
|
37 |
Returns a new executor that uses the given block to execute continuations. |
|
38 |
@param block The block to use. |
|
39 |
*/ |
13e53a
|
40 |
+ (instancetype)executorWithBlock:(void(^)(void(^block)(void)))block; |
bad748
|
41 |
|
W |
42 |
/*! |
|
43 |
Returns a new executor that runs continuations on the given queue. |
|
44 |
@param queue The instance of `dispatch_queue_t` to dispatch all continuations onto. |
|
45 |
*/ |
|
46 |
+ (instancetype)executorWithDispatchQueue:(dispatch_queue_t)queue; |
|
47 |
|
|
48 |
/*! |
|
49 |
Returns a new executor that runs continuations on the given queue. |
|
50 |
@param queue The instance of `NSOperationQueue` to run all continuations on. |
|
51 |
*/ |
|
52 |
+ (instancetype)executorWithOperationQueue:(NSOperationQueue *)queue; |
|
53 |
|
|
54 |
/*! |
|
55 |
Runs the given block using this executor's particular strategy. |
|
56 |
@param block The block to execute. |
|
57 |
*/ |
13e53a
|
58 |
- (void)execute:(void(^)(void))block; |
bad748
|
59 |
|
W |
60 |
@end |
|
61 |
|
|
62 |
NS_ASSUME_NONNULL_END |