ConcurrentOperation.m
author Jens Alfke <jens@mooseyard.com>
Thu Mar 20 09:05:58 2008 -0700 (2008-03-20)
changeset 1 e55a17cdabd2
child 11 e5976864dfe9
permissions -rw-r--r--
Configurable logging (LogTo).
Added "my_" prefix to category method names.
Added MurmurHash.
Added UniqueWindowController.
Bug fixes.
     1 //
     2 //  ConcurrentOperation.m
     3 //  MYUtilities
     4 //
     5 //  Created by Jens Alfke on 2/5/08.
     6 //  Copyright 2008 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import "ConcurrentOperation.h"
    10 
    11 // 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
    12 
    13 
    14 @implementation ConcurrentOperation
    15 
    16 
    17 - (BOOL) isConcurrent {return YES;}
    18 
    19 - (void) main
    20 {
    21     Assert(NO,@"Shouldn't call -main method of ConcurrentOperation");
    22 }
    23 
    24 - (BOOL) isExecuting
    25 {
    26     return _isExecuting;
    27 }
    28 
    29 - (BOOL) isFinished
    30 {
    31     return _isFinished;
    32 }
    33 
    34 - (void) start
    35 {
    36     // don't call super!
    37     Log(@"Starting %@",self);
    38     [self willChangeValueForKey: @"isExecuting"];
    39     _isExecuting = YES;
    40     [self didChangeValueForKey: @"isExecuting"];
    41 }
    42 
    43 - (void) finish
    44 {
    45     Log(@"Finished %@",self);
    46     [self willChangeValueForKey: @"isExecuting"];
    47     [self willChangeValueForKey: @"isFinished"];
    48     _isExecuting = NO;
    49     _isFinished = YES;
    50     [self didChangeValueForKey: @"isFinished"];
    51     [self didChangeValueForKey: @"isExecuting"];
    52 }
    53 
    54 
    55 - (void) cancel
    56 {
    57     Log(@"Canceling %@",self);
    58     [super cancel];
    59     if( _isExecuting ) {
    60         [self willChangeValueForKey: @"isExecuting"];
    61         _isExecuting = NO;
    62         [self didChangeValueForKey: @"isExecuting"];
    63     }
    64 }
    65 
    66 
    67 @end