4 #import "CKKSProvideKeySetOperation.h"
6 @interface CKKSProvideKeySetOperation ()
7 @property (nullable) CKKSCurrentKeySet* keyset;
8 @property dispatch_queue_t queue;
10 @property (nullable) NSOperation* startDependency;
13 @implementation CKKSProvideKeySetOperation
14 @synthesize zoneName = _zoneName;
15 @synthesize keyset = _keyset;
17 - (instancetype)initWithZoneName:(NSString*)zoneName
19 if((self = [super init])) {
22 _startDependency = [NSBlockOperation blockOperationWithBlock:^{}];
23 _startDependency.name = @"key-set-provided";
25 _queue = dispatch_queue_create("key-set-queue", DISPATCH_QUEUE_SERIAL);
27 [self addDependency:_startDependency];
32 - (void)provideKeySet:(CKKSCurrentKeySet *)keyset
34 // Ensure that only one keyset is provided through each operation
35 dispatch_sync(self.queue, ^{
38 if(self.startDependency) {
39 // Create a new queue here, just to be safe in case someone is waiting
40 NSOperationQueue* queue = [[NSOperationQueue alloc] init];
41 [queue addOperation:self.startDependency];
42 self.startDependency = nil;