diff -r 000000000000 -r 3d3dcc3116d5 ConcurrentOperation.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ConcurrentOperation.m Wed Apr 02 14:45:33 2008 -0700 @@ -0,0 +1,67 @@ +// +// ConcurrentOperation.m +// MYUtilities +// +// Created by Jens Alfke on 2/5/08. +// Copyright 2008 Jens Alfke. All rights reserved. +// + +#import "ConcurrentOperation.h" + +// 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 + + +@implementation ConcurrentOperation + + +- (BOOL) isConcurrent {return YES;} + +- (void) main +{ + Assert(NO,@"Shouldn't call -main method of ConcurrentOperation"); +} + +- (BOOL) isExecuting +{ + return _isExecuting; +} + +- (BOOL) isFinished +{ + return _isFinished; +} + +- (void) start +{ + // don't call super! + Log(@"Starting %@",self); + [self willChangeValueForKey: @"isExecuting"]; + _isExecuting = YES; + [self didChangeValueForKey: @"isExecuting"]; +} + +- (void) finish +{ + Log(@"Finished %@",self); + [self willChangeValueForKey: @"isExecuting"]; + [self willChangeValueForKey: @"isFinished"]; + _isExecuting = NO; + _isFinished = YES; + [self didChangeValueForKey: @"isFinished"]; + [self didChangeValueForKey: @"isExecuting"]; +} + + +- (void) cancel +{ + Log(@"Canceling %@",self); + [super cancel]; + if( _isExecuting ) { + [self willChangeValueForKey: @"isExecuting"]; + _isExecuting = NO; + [self didChangeValueForKey: @"isExecuting"]; + } +} + + +@end