NSOperation documentation omission
| Originator: | ckrames1234 | ||
| Number: | rdar://12801350 | Date Originated: | 03-Dec-2012 07:24 PM |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 6.0 |
| Classification: | Other Bug | Reproducible: | Not Applicable |
Summary:
The documentation for NSOperation fails to explain that when Operation 2 is dependent on Operation 1, Operation 2 will not begin to execute until the completion block for Operation 1 has finished executing.
Steps to Reproduce:
1. Execute the following code:
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
NSBlockOperation *op1 = [NSBlockOperation blockOperationWithBlock:^{ NSLog(@"Operation 1 work!"); }];
[op1 setCompletionBlock:^{ sleep(5); NSLog(@"Operation 1 done!"); }];
NSBlockOperation *op2 = [NSBlockOperation blockOperationWithBlock:^{ NSLog(@"Operation 2 work!"); }];
[op2 setCompletionBlock:^{ NSLog(@"Operation 2 done!"); }];
[op2 addDependency:op1];
[queue addOperation:op1];
[queue addOperation:op2];
Expected Results:
According to the documentation:
"The completion block you provide is executed when the value returned by the isFinished method changes to YES."
"An operation object does not clear a dependency until the value at the isFinished key path changes to YES."
I would expect both the completionBlock of op1 and op2 to execute simultaneously, when the operation is completed.
Actual Results:
The second operation, op2, does not execute until both op1 is marked as finished *and* its completion block finishes executing. Something not explained in the documentation.
Regression:
N/A
Notes:
N/A
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!