Permalink
Browse files

BatchProxy fixes - passing basic test

  • Loading branch information...
1 parent 638969e commit 325deca352a14dc70e1702c5d28dd618936b0de9 @stevedekorte committed Sep 15, 2011
Showing with 22 additions and 7 deletions.
  1. +1 −0 ActorKit/ActorKit.h
  2. +16 −5 ActorKit/BatchProxy.m
  3. +3 −2 ActorKit/NSInvocation+Copy.m
  4. +2 −0 README.txt
View
@@ -10,6 +10,7 @@
#import "BatchProxy.h"
#import "SyncProxy.h"
#import "NSObject+Actor.h"
+#import "NSArray+Actor.h"
// private
View
@@ -49,21 +49,25 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation
NSStringFromSelector([anInvocation selector])]];
}
- NSInteger length = [batchTarget length];
- id *results = calloc(0, sizeof(id) * length);
-
[anInvocation retainArguments];
-
+
+ NSInteger length = [batchTarget count];
+ id *results = calloc(0, sizeof(id) * length);
+
dispatch_apply(length, [self batchDispatchQueue],
^(size_t i)
{
+ //printf("start %i\n", (int)i);
id item = [batchTarget objectAtIndex:i];
NSInvocation *copyInvocation = [anInvocation copy];
+ [copyInvocation retain];
[copyInvocation invokeWithTarget:item];
id r;
[copyInvocation getReturnValue:&r];
results[i] = r;
+ [copyInvocation release];
+ //printf("end %i\n", (int)i);
}
);
@@ -77,7 +81,14 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
- return [batchTarget methodSignatureForSelector:aSelector];
+ if([batchTarget count])
+ {
+ id firstObject = [batchTarget objectAtIndex:0];
+ NSMethodSignature *sig = [firstObject methodSignatureForSelector:aSelector];
+ return sig;
+ }
+
+ return nil;
}
@end
@@ -16,16 +16,17 @@ - (id)copy
NSInvocation *copy = [NSInvocation invocationWithMethodSignature:[self methodSignature]];
[copy setTarget:[self target]];
[copy setSelector:[self selector]];
+
char buffer[sizeof(intmax_t)];
NSUInteger argCount = [[self methodSignature] numberOfArguments];
- for (int i = 0; i < argCount; i++)
+ for (int i = 2; i < argCount; i++)
{
[self getArgument:(void *)&buffer atIndex:i];
[copy setArgument:(void *)&buffer atIndex:i];
}
-
+
return copy;
}
View
@@ -92,6 +92,8 @@ Notes
To Do
+ - handle BatchProxy exceptions
+
- extend collection classes to use workqueues for makeObjectsPerform: etc
- future notifications of some kind

0 comments on commit 325deca

Please sign in to comment.