Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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.

@JaviSoto JaviSoto commented on the diff Mar 28, 2013

Zinc/ZincOperation.m
@@ -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?

@JaviSoto JaviSoto commented on the diff Mar 28, 2013

Zinc/NSOperation+Zinc.m
+//
+// NSOperation+Zinc.m
+// Zinc-ObjC
+//
+// Created by Andy Mroczkowski on 3/28/13.
+// Copyright (c) 2013 MindSnacks. All rights reserved.
+//
+
+#import "NSOperation+Zinc.h"
+
+@implementation NSOperation (Zinc)
+
+- (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.

@JaviSoto JaviSoto commented on the diff Mar 28, 2013

Zinc/NSOperation+Zinc.m
@@ -0,0 +1,38 @@
+//
+// NSOperation+Zinc.m
+// Zinc-ObjC
+//
+// Created by Andy Mroczkowski on 3/28/13.
+// Copyright (c) 2013 MindSnacks. All rights reserved.
+//
+
+#import "NSOperation+Zinc.h"
+
+@implementation NSOperation (Zinc)
+
+- (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