jens@0: // jens@0: // ConcurrentOperation.m jens@0: // MYUtilities jens@0: // jens@0: // Created by Jens Alfke on 2/5/08. jens@0: // Copyright 2008 Jens Alfke. All rights reserved. jens@0: // jens@0: jens@0: #import "ConcurrentOperation.h" jens@0: jens@0: // See file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html#//apple_ref/doc/uid/TP40004591-RH2-DontLinkElementID_4 jens@0: jens@0: jens@0: @implementation ConcurrentOperation jens@0: jens@0: jens@0: - (BOOL) isConcurrent {return YES;} jens@0: jens@0: - (void) main jens@0: { jens@0: Assert(NO,@"Shouldn't call -main method of ConcurrentOperation"); jens@0: } jens@0: jens@0: - (BOOL) isExecuting jens@0: { jens@0: return _isExecuting; jens@0: } jens@0: jens@0: - (BOOL) isFinished jens@0: { jens@0: return _isFinished; jens@0: } jens@0: jens@0: - (void) start jens@0: { jens@0: // don't call super! jens@0: Log(@"Starting %@",self); jens@0: [self willChangeValueForKey: @"isExecuting"]; jens@0: _isExecuting = YES; jens@0: [self didChangeValueForKey: @"isExecuting"]; jens@0: } jens@0: jens@0: - (void) finish jens@0: { jens@0: Log(@"Finished %@",self); jens@0: [self willChangeValueForKey: @"isExecuting"]; jens@0: [self willChangeValueForKey: @"isFinished"]; jens@0: _isExecuting = NO; jens@0: _isFinished = YES; jens@0: [self didChangeValueForKey: @"isFinished"]; jens@0: [self didChangeValueForKey: @"isExecuting"]; jens@0: } jens@0: jens@0: jens@0: - (void) cancel jens@0: { jens@0: Log(@"Canceling %@",self); jens@0: [super cancel]; jens@0: if( _isExecuting ) { jens@0: [self willChangeValueForKey: @"isExecuting"]; jens@0: _isExecuting = NO; jens@0: [self didChangeValueForKey: @"isExecuting"]; jens@0: } jens@0: } jens@0: jens@0: jens@0: @end