Re: NSPipe (NSFileHandle) writedata limit?
Re: NSPipe (NSFileHandle) writedata limit?
- Subject: Re: NSPipe (NSFileHandle) writedata limit?
- From: "McLaughlin, Michael P." <email@hidden>
- Date: Fri, 9 Apr 2010 13:35:37 -0400
- Acceptlanguage: en-US
- Thread-topic: NSPipe (NSFileHandle) writedata limit?
I am not getting an error; it just hangs.
*** code ***
@interface Subtask : NSObject {
NSTask *aTask;
NSPipe *inPipe, *outPipe;
NSFileHandle *sendEnd, *readEnd;
NSString *myID;
}
-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag:(NSString*)tag;
...
@end
// in implementation
aTask = [NSTask new];
...
myID = [NSString stringWithFormat:@"%d ", ident];
inPipe = [NSPipe pipe]; // i.e., input for subtask
outPipe = [NSPipe pipe];
sendEnd = [inPipe fileHandleForWriting];
readEnd = [outPipe fileHandleForReading];
...
-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag:(NSString*)tag
{
NSData *dataset = [NSData dataWithBytes:data length:sz];
NSNumber *num = [NSNumber numberWithUnsignedInteger:sz];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: num, @"size", nil];
[sendEnd writeData:dataset]; // Do NOT close the fileHandle!
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:tag object:myID userInfo:dict];
}
*** end code ***
My main thread has an NSArray of Subtasks and sends data to each via
Npending = numProcessors;
for (k = 0;k < numProcessors;k++) {
Subtask *aTask = [myTask objectAtIndex:k];
[aTask sendData:&theData numBytes:sz taskTag:@"aTag"];
}
If sz < 65536, this works; otherwise it hangs at
[sendEnd writeData:dataset];
Note: GC is supported.
On 4/9/10 12:29 PM, "Dave Keck" <email@hidden> wrote:
After re-reading your message, I think I misunderstood your problem.
Nonetheless, a quick test program doesn't run into the mentioned 65k
limit (at least on my machine):
http://pastie.org/911738
Still though, what error are you getting?
--
Mike McLaughlin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden