Skip to content

Commit

Permalink
BatchProxy fixes - passing basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedekorte committed Sep 15, 2011
1 parent 638969e commit 325deca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions ActorKit/ActorKit.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "BatchProxy.h" #import "BatchProxy.h"
#import "SyncProxy.h" #import "SyncProxy.h"
#import "NSObject+Actor.h" #import "NSObject+Actor.h"
#import "NSArray+Actor.h"


// private // private


Expand Down
21 changes: 16 additions & 5 deletions ActorKit/BatchProxy.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation
NSStringFromSelector([anInvocation selector])]]; NSStringFromSelector([anInvocation selector])]];
} }


NSInteger length = [batchTarget length];
id *results = calloc(0, sizeof(id) * length);

[anInvocation retainArguments]; [anInvocation retainArguments];


NSInteger length = [batchTarget count];
id *results = calloc(0, sizeof(id) * length);

dispatch_apply(length, [self batchDispatchQueue], dispatch_apply(length, [self batchDispatchQueue],
^(size_t i) ^(size_t i)
{ {
//printf("start %i\n", (int)i);
id item = [batchTarget objectAtIndex:i]; id item = [batchTarget objectAtIndex:i];
NSInvocation *copyInvocation = [anInvocation copy]; NSInvocation *copyInvocation = [anInvocation copy];
[copyInvocation retain];
[copyInvocation invokeWithTarget:item]; [copyInvocation invokeWithTarget:item];


id r; id r;
[copyInvocation getReturnValue:&r]; [copyInvocation getReturnValue:&r];
results[i] = r; results[i] = r;
[copyInvocation release];
//printf("end %i\n", (int)i);
} }
); );


Expand All @@ -77,7 +81,14 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation


- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector - (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 @end
5 changes: 3 additions & 2 deletions ActorKit/NSInvocation+Copy.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ - (id)copy
NSInvocation *copy = [NSInvocation invocationWithMethodSignature:[self methodSignature]]; NSInvocation *copy = [NSInvocation invocationWithMethodSignature:[self methodSignature]];
[copy setTarget:[self target]]; [copy setTarget:[self target]];
[copy setSelector:[self selector]]; [copy setSelector:[self selector]];

char buffer[sizeof(intmax_t)]; char buffer[sizeof(intmax_t)];


NSUInteger argCount = [[self methodSignature] numberOfArguments]; 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]; [self getArgument:(void *)&buffer atIndex:i];
[copy setArgument:(void *)&buffer atIndex:i]; [copy setArgument:(void *)&buffer atIndex:i];
} }

return copy; return copy;
} }


Expand Down
2 changes: 2 additions & 0 deletions README.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Notes


To Do To Do


- handle BatchProxy exceptions

- extend collection classes to use workqueues for makeObjectsPerform: etc - extend collection classes to use workqueues for makeObjectsPerform: etc


- future notifications of some kind - future notifications of some kind
Expand Down

0 comments on commit 325deca

Please sign in to comment.