@@ -86,7 +86,7 @@ - (BNCServerRequest *)removeAt:(unsigned int)index {
86
86
BNCLogError (@" Invalid queue operation: index out of bound!" );
87
87
return nil ;
88
88
}
89
-
89
+
90
90
request = [self .queue objectAtIndex: index];
91
91
[self .queue removeObjectAtIndex: index];
92
92
[self persistEventually ];
@@ -111,10 +111,10 @@ - (BNCServerRequest *)peekAt:(unsigned int)index {
111
111
BNCLogError (@" Invalid queue operation: index out of bound!" );
112
112
return nil ;
113
113
}
114
-
114
+
115
115
BNCServerRequest *request = nil ;
116
116
request = [self .queue objectAtIndex: index];
117
-
117
+
118
118
return request;
119
119
}
120
120
}
@@ -176,7 +176,7 @@ - (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount {
176
176
for (int i = 0 ; i < self.queue .count ; i++) {
177
177
BNCServerRequest *req = [self .queue objectAtIndex: i];
178
178
if ([req isKindOfClass: [BranchOpenRequest class ]]) {
179
-
179
+
180
180
// Already in front, nothing to do
181
181
if (i == 0 || (i == 1 && requestAlreadyInProgress)) {
182
182
return (BranchOpenRequest *)req;
@@ -187,19 +187,19 @@ - (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount {
187
187
break ;
188
188
}
189
189
}
190
-
190
+
191
191
if (!openOrInstallRequest) {
192
192
BNCLogError (@" No install or open request in queue while trying to move it to the front." );
193
193
return nil ;
194
194
}
195
-
195
+
196
196
if (!requestAlreadyInProgress || !self.queue .count ) {
197
197
[self insert: openOrInstallRequest at: 0 ];
198
198
}
199
199
else {
200
200
[self insert: openOrInstallRequest at: 1 ];
201
201
}
202
-
202
+
203
203
return (BranchOpenRequest *)openOrInstallRequest;
204
204
}
205
205
}
@@ -233,9 +233,9 @@ - (void)persistEventually {
233
233
BNCNanoSecondsFromTimeInterval (BATCH_WRITE_TIMEOUT),
234
234
BNCNanoSecondsFromTimeInterval (BATCH_WRITE_TIMEOUT / 10.0 )
235
235
);
236
- __weak typeof (self) weakSelf = self;
236
+ __weak __typeof (self) weakSelf = self;
237
237
dispatch_source_set_event_handler (self.persistTimer , ^ {
238
- __strong typeof (self) strongSelf = weakSelf;
238
+ __strong __typeof (self) strongSelf = weakSelf;
239
239
if (strongSelf) {
240
240
[strongSelf persistImmediately ];
241
241
dispatch_source_cancel (strongSelf.persistTimer );
@@ -290,7 +290,7 @@ - (void)retrieve {
290
290
@synchronized (self) {
291
291
NSMutableArray *queue = [[NSMutableArray alloc ] init ];
292
292
NSArray *encodedRequests = nil ;
293
-
293
+
294
294
// Capture exception while loading the queue file
295
295
@try {
296
296
NSError *error = nil ;
@@ -325,21 +325,21 @@ - (void)retrieve {
325
325
BNCLogWarning (@" An exception occurred while attempting to parse a queued request, discarding." );
326
326
continue ;
327
327
}
328
-
328
+
329
329
// Throw out invalid request types
330
330
if (![request isKindOfClass: [BNCServerRequest class ]]) {
331
331
BNCLogWarning (@" Found an invalid request object, discarding. Object is: %@ ." , request);
332
332
continue ;
333
333
}
334
-
334
+
335
335
// Throw out persisted close requests
336
336
if ([request isKindOfClass: [BranchCloseRequest class ]]) {
337
337
continue ;
338
338
}
339
339
340
340
[queue addObject: request];
341
341
}
342
-
342
+
343
343
self.queue = queue;
344
344
}
345
345
}
@@ -367,9 +367,9 @@ + (NSURL* _Nonnull) URLForQueueFile {
367
367
+ (void ) moveOldQueueFile {
368
368
NSURL *oldURL = [NSURL fileURLWithPath: self .queueFile_deprecated];
369
369
NSURL *newURL = [self URLForQueueFile ];
370
-
370
+
371
371
if (!oldURL || !newURL) { return ; }
372
-
372
+
373
373
NSError *error = nil ;
374
374
[[NSFileManager defaultManager ]
375
375
moveItemAtURL: oldURL
@@ -398,7 +398,7 @@ + (void) initialize {
398
398
+ (id )getInstance {
399
399
static BNCServerRequestQueue *sharedQueue = nil ;
400
400
static dispatch_once_t onceToken;
401
-
401
+
402
402
dispatch_once (&onceToken, ^ {
403
403
sharedQueue = [[BNCServerRequestQueue alloc ] init ];
404
404
[sharedQueue retrieve ];
0 commit comments