Re: Sleeping and waking NSThread
Re: Sleeping and waking NSThread
- Subject: Re: Sleeping and waking NSThread
- From: Mark Alldritt <email@hidden>
- Date: Mon, 21 Jun 2004 10:32:48 -0700
>
> Hi,
>
>
>
> I have a need to make a thread sleep until a reply arrives for an
>
> AppleEvent. I can see how to make NSThread sleep with sleepUntilDate:
>
> with
>
> a sufficiently long expiration, but I cannot see a call that will wake
>
> a
>
> thread up again. Does anyone know how this is done?
>
>
You likely want to block the thread on a lock of some type
>
(NSConditionLock possibly) or connect up a event source with a run loop
>
(NSRunloop) running in that thread, etc.
I see.
I've just checked out NSConditionLock at it seems simple enough. Can you
point me an example illustrating how I might use an event source for an run
loop?
>
Anyway how are you sending the AppleEvent? How are you setup to get a
>
reply back?
>
>
Depending on what you have it can affect what would be the best method.
The AppleEvent manager is not thread aware, so the only way to approach this
is to use Queued Replies. In this configuration, I get an answer event
which I catch with my own event handler. I then match up the event return
IDs and route the reply to the correct waiting thread (I may have several
with pending AppleEvents targeting different applications).
I'm porting this code from a legacy Carbon application which uses Carbon's
cooperative threading model.
Cheers
-Mark
---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB:
http://www.latenightsw.com/ CANADA V8V-4M9
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.