75 JSObject _completionFunction;
76 CPArray _dependencies;
94 _dependencies = [[CPArray alloc] init];
107 [
self willChangeValueForKey:@"isExecuting"];
109 [
self didChangeValueForKey:@"isExecuting"];
111 if (_completionFunction)
113 _completionFunction();
115 [
self willChangeValueForKey:@"isExecuting"];
117 [
self didChangeValueForKey:@"isExecuting"];
118 [
self willChangeValueForKey:@"isFinished"];
120 [
self didChangeValueForKey:@"isFinished"];
173 - (JSObject)completionFunction
175 return _completionFunction;
181 - (void)setCompletionFunction:(JSObject)aJavaScriptFunction
183 _completionFunction = aJavaScriptFunction;
192 [
self willChangeValueForKey:@"dependencies"];
193 [anOperation addObserver:self
194 forKeyPath:@"isFinished"
195 options:(CPKeyValueObservingOptionNew)
197 [_dependencies addObject:anOperation];
198 [
self didChangeValueForKey:@"dependencies"];
199 [
self _updateIsReadyState];
208 [
self willChangeValueForKey:@"dependencies"];
209 [_dependencies removeObject:anOperation];
210 [anOperation removeObserver:self
211 forKeyPath:@"isFinished"];
212 [
self didChangeValueForKey:@"dependencies"];
213 [
self _updateIsReadyState];
220 - (CPArray)dependencies
222 return _dependencies;
228 - (void)waitUntilFinished
237 [
self willChangeValueForKey:@"isCancelled"];
239 [
self didChangeValueForKey:@"isCancelled"];
246 - (void)setQueuePriority:(
int)priority
248 _queuePriority = priority;
257 return _queuePriority;
264 context:(
void)context
266 if (keyPath ==
@"isFinished")
268 [
self _updateIsReadyState];
272 - (void)_updateIsReadyState
275 if (_dependencies && [_dependencies count] > 0)
278 for (i = 0; i < [_dependencies count]; i++)
280 if (![[_dependencies objectAtIndex:i] isFinished])
287 if (newReady != _ready)
289 [
self willChangeValueForKey:@"isReady"];
291 [
self didChangeValueForKey:@"isReady"];