Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOAsyncWorkManagerInternal Class Reference
+ Inheritance diagram for OOAsyncWorkManagerInternal:
+ Collaboration diagram for OOAsyncWorkManagerInternal:

Instance Methods

(void) - queueResult:
 
(void) - noteTaskQueued:
 
(id) - init [implementation]
 
(void) - completePendingTasks [implementation]
 
(void) - waitForTaskToComplete: [implementation]
 
- Instance Methods inherited from OOAsyncWorkManager
(BOOL) - addTask:priority:
 
(void) - dealloc [implementation]
 
(oneway void) - release [implementation]
 
(id) - retain [implementation]
 
(NSUInteger) - retainCount [implementation]
 

Private Attributes

OOAsyncQueue_readyQueue
 
NSMutableSet * _pendingCompletableOperations
 
NSLock * _pendingOpsLock
 

Additional Inherited Members

- Class Methods inherited from OOAsyncWorkManager
(OOAsyncWorkManager *) + sharedAsyncWorkManager
 
(id) + allocWithZone: [implementation]
 

Detailed Description

Definition at line 56 of file OOAsyncWorkManager.m.

Method Documentation

◆ completePendingTasks

- (void) completePendingTasks
implementation

Reimplemented from OOAsyncWorkManager.

Definition at line 88 of file OOAsyncWorkManager.m.

252{
253 id next = nil;
254
255 [_pendingOpsLock lock];
256 for (;;)
257 {
258 next = [_readyQueue tryDequeue];
259 if (next == nil) break;
260
261 [_pendingCompletableOperations removeObject:next];
262 [next completeAsyncTask];
263 }
264 [_pendingOpsLock unlock];
265}
return nil

◆ init

- (id) init
implementation

Reimplemented in OOOperationQueueAsyncWorkManager.

Definition at line 88 of file OOAsyncWorkManager.m.

226{
227 if ((self = [super init]))
228 {
229 _readyQueue = [[OOAsyncQueue alloc] init];
230
231 if (_readyQueue == nil)
232 {
233 [self release];
234 return nil;
235 }
236
237 _pendingCompletableOperations = [[NSMutableSet alloc] init];
238 _pendingOpsLock = [[NSLock alloc] init];
239
241 {
242 [self release];
243 return nil;
244 }
245 }
246
247 return self;
248}
NSMutableSet * _pendingCompletableOperations

◆ noteTaskQueued:

- (void) noteTaskQueued: (id<OOAsyncWorkTask>) task

Definition at line 88 of file OOAsyncWorkManager.m.

308 :(id<OOAsyncWorkTask>)task
309{
310 [_pendingOpsLock lock];
311 [_pendingCompletableOperations addObject:task];
312 [_pendingOpsLock unlock];
313}

◆ queueResult:

- (void) queueResult: (id<OOAsyncWorkTask>) task

Definition at line 88 of file OOAsyncWorkManager.m.

299 :(id<OOAsyncWorkTask>)task
300{
301 if ([task respondsToSelector:@selector(completeAsyncTask)])
302 {
303 [_readyQueue enqueue:task];
304 }
305}

◆ waitForTaskToComplete:

- (void) waitForTaskToComplete: (id<OOAsyncWorkTask>) task
implementation

Reimplemented from OOAsyncWorkManager.

Definition at line 88 of file OOAsyncWorkManager.m.

268 :(id<OOAsyncWorkTask>)task
269{
270 if (task == nil) return;
271
272#if OO_DEBUG
273 NSParameterAssert([(id)task respondsToSelector:@selector(completeAsyncTask)]);
274 NSAssert1(![NSThread respondsToSelector:@selector(isMainThread)] || [[NSThread self] isMainThread], @"%s can only be called from the main thread.", __PRETTY_FUNCTION__);
275#endif
276
277 [_pendingOpsLock lock];
278 BOOL exists = [_pendingCompletableOperations containsObject:task];
279 if (exists) [_pendingCompletableOperations removeObject:task];
280 [_pendingOpsLock unlock];
281
282 if (!exists) return;
283
284 id next = nil;
285 do
286 {
287 // Dequeue a task and complete it.
288 next = [_readyQueue dequeue];
289 [_pendingOpsLock lock];
290 [_pendingCompletableOperations removeObject:next];
291 [_pendingOpsLock unlock];
292
293 [next completeAsyncTask];
294
295 } while (next != task); // We don't control order, so keep looking until we get the one we care about.
296}

Member Data Documentation

◆ _pendingCompletableOperations

- (NSMutableSet*) _pendingCompletableOperations
private

Definition at line 61 of file OOAsyncWorkManager.m.

◆ _pendingOpsLock

- (NSLock*) _pendingOpsLock
private

Definition at line 62 of file OOAsyncWorkManager.m.

◆ _readyQueue

- (OOAsyncQueue*) _readyQueue
private

Definition at line 59 of file OOAsyncWorkManager.m.


The documentation for this class was generated from the following file: