Fwd: Setting up an auxiliary task for use with Distributed Objects
Fwd: Setting up an auxiliary task for use with Distributed Objects
- Subject: Fwd: Setting up an auxiliary task for use with Distributed Objects
- From: "Jeremy W. Sherman" <email@hidden>
- Date: Thu, 16 Apr 2009 09:28:21 -0400
Apologies for the multiple-send. Keep forgetting to reply to all.
Looking to see if I can set that as default or just have to start
slapping myself for negative reinforcement instead.
---------- Forwarded message ----------
From: Jeremy W. Sherman <email@hidden>
Date: Thu, Apr 16, 2009 at 9:26 AM
Subject: Re: Setting up an auxiliary task for use with Distributed Objects
To: Oleg Krupnov <email@hidden>
You can communicate with the task, since you seem to control it, by
setting up a pipe (NSPipe) and setting its write/read file handles as
the stdin/stdout for the task. The task can then send you a "ready to
go" signal. You can use -[NSFileHandle
waitForDataInBackgroundAndNotify] to get a callback when the "ready"
signal is sent back. On the other side, you can have it check for a
broken connection (is that possible with NSConnection/NSMachPort?) or
just wait for a kill message to come across on its stdin, which your
primary task can send over.
I've not had much luck with DO, so there might be a better way out there.
—Jeremy
On Thu, Apr 16, 2009 at 5:01 AM, Oleg Krupnov <email@hidden> wrote:
> I'm looking for the right way of setting up the auxiliary NSTask from
> within the main task. The aux task vends some Distributed Objects, and
> the main task uses them.
>
> The auxiliary task does this:
>
> NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>
> MyVendedObject* vendedObj = [[[MyVendedObject alloc] init] autorelease];
>
> NSConnection* connection = [NSConnection defaultConnection];
> [connection setRootObject:vendedObj];
> if ([connection registerName:@"MyAuxTask"])
> {
> [[NSRunLoop currentRunLoop] run];
> }
>
> [pool release];
> return 0;
>
> As I understand, as soon as the aux tasks reaches the runloop's run
> message, it blocks and is ready for connection messages.
>
> However there are 2 problems:
>
> 1) I need to block the main task until the aux task is ready to work.
> How do I do it? Sleep/poll connection/repeat doesn't seem a good
> approach, is there any better way?
>
> 2) How do I quit the aux task? [NSTask terminate] does not work,
> invalidating the connection does not work...
> _______________________________________________
>
> 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
>
_______________________________________________
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