Attempt to detect circular dependencies in operations #69

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

amrox commented Mar 28, 2013

No description provided.

@@ -58,4 +59,10 @@ - (float) progress
return ZincProgressCalculate(self);
}
+- (void)addDependency:(NSOperation *)op
+{
+ NSAssert(![[op zinc_allDependencies] containsObject:self], @"attempt to add circular dependency");
@JaviSoto

JaviSoto Mar 28, 2013

Collaborator

For what we know, this is probably going to crash in develop now, right?

@JaviSoto

JaviSoto Mar 28, 2013

Collaborator

Maybe add self and op to the assert message?

Collaborator

JaviSoto commented Mar 28, 2013

maybe write a test for this?

+- (NSArray*) zinc_allDependencies
+{
+ NSMutableArray *todo = [NSMutableArray arrayWithObject:self];
+ NSMutableSet *done = [NSMutableSet set];
@JaviSoto

JaviSoto Mar 28, 2013

Collaborator

Maybe rename this to visitedOperations, helps understand the algorithm better.

+
+- (NSArray*) zinc_allDependencies
+{
+ NSMutableArray *todo = [NSMutableArray arrayWithObject:self];
@JaviSoto

JaviSoto Mar 28, 2013

Collaborator

Rename this to pendingOperationsToVisit also makes it more clear.

@amrox amrox closed this May 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment