McLaughlin, Michael P. wrote:

main --> subtask (main send data)

-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag: (NSString*)tag
{
   NSData *dataset = [NSData dataWithBytes:data length:sz];
NSNumber *num = [NSNumber numberWithUnsignedInteger:sz]; // NSUInteger NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: num,
@"size", nil];
   [sendEnd writeData:dataset];    // Do NOT close the fileHandle!
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:tag
object:myID userInfo:dict];
}

That is, main
1) sends (via FileHandle and pipe) a known quantity of data to the subtask
and
2) tells it what sort of data are coming and how much.


All that stuff I just wrote?  Uh, never mind.

There's your deadlock right there.

You must send the notification with size and such BEFORE writing to the pipe. Otherwise the sender can become blocked, because the receiver doesn't know it should be reading anything.

If you'd been sending the size over the pipe, it would have been obvious. You have to tell the receiver how many bytes follow.

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to