-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cancellation is provided by a token passed into the continuation methods, which check for the cancelled state before executing their blocks and return a cancelled BFTask if necessary.
- Loading branch information
1 parent
c1cf44c
commit fd6e142
Showing
9 changed files
with
267 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// BFTaskCancellationToken.h | ||
// Bolts | ||
// | ||
// Created by Daniel Hammond on 12/5/14. | ||
// Copyright (c) 2014 Parse Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface BFTaskCancellationToken : NSObject | ||
|
||
@property (nonatomic, assign, readonly, getter=isCancelled) BOOL cancelled; | ||
- (void)cancel; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// BFTaskCancellationToken.m | ||
// Bolts | ||
// | ||
// Created by Daniel Hammond on 12/5/14. | ||
// Copyright (c) 2014 Parse Inc. All rights reserved. | ||
// | ||
|
||
#import "BFTaskCancellationToken.h" | ||
|
||
@interface BFTaskCancellationToken () | ||
|
||
@property (atomic, assign, readwrite, getter=isCancelled) BOOL cancelled; | ||
@property (nonatomic, retain) NSObject *lock; | ||
|
||
@end | ||
|
||
@implementation BFTaskCancellationToken | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
_lock = [[NSObject alloc] init]; | ||
return self; | ||
} | ||
|
||
- (BOOL)isCancelled { | ||
@synchronized (self.lock) { | ||
return _cancelled; | ||
} | ||
} | ||
|
||
- (void)cancel { | ||
@synchronized (self.lock) { | ||
self.cancelled = YES; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.