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 |
@class BFCancellationToken; |
|
16 |
|
|
17 |
/*! |
|
18 |
BFCancellationTokenSource represents the producer side of a CancellationToken. |
|
19 |
Signals to a CancellationToken that it should be canceled. |
|
20 |
It is a cancellation token that also has methods |
|
21 |
for changing the state of a token by cancelling it. |
|
22 |
*/ |
|
23 |
@interface BFCancellationTokenSource : NSObject |
|
24 |
|
|
25 |
/*! |
|
26 |
Creates a new cancellation token source. |
|
27 |
*/ |
|
28 |
+ (instancetype)cancellationTokenSource; |
|
29 |
|
|
30 |
/*! |
|
31 |
The cancellation token associated with this CancellationTokenSource. |
|
32 |
*/ |
|
33 |
@property (nonatomic, strong, readonly) BFCancellationToken *token; |
|
34 |
|
|
35 |
/*! |
|
36 |
Whether cancellation has been requested for this token source. |
|
37 |
*/ |
|
38 |
@property (nonatomic, assign, readonly, getter=isCancellationRequested) BOOL cancellationRequested; |
|
39 |
|
|
40 |
/*! |
|
41 |
Cancels the token if it has not already been cancelled. |
|
42 |
*/ |
|
43 |
- (void)cancel; |
|
44 |
|
|
45 |
/*! |
|
46 |
Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds. |
|
47 |
@param millis The number of milliseconds to wait before completing the returned task. |
|
48 |
If delay is `0` the cancel is executed immediately. If delay is `-1` any scheduled cancellation is stopped. |
|
49 |
*/ |
|
50 |
- (void)cancelAfterDelay:(int)millis; |
|
51 |
|
|
52 |
/*! |
|
53 |
Releases all resources associated with this token source, |
|
54 |
including disposing of all registrations. |
|
55 |
*/ |
|
56 |
- (void)dispose; |
|
57 |
|
|
58 |
@end |
|
59 |
|
|
60 |
NS_ASSUME_NONNULL_END |