discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to terminate another thread?


From: David Ayers
Subject: RE: How to terminate another thread?
Date: Wed, 24 Jul 2002 09:06:06 +0200

Hi Stefan,

> Well, I need it for several objects of different classes and they
> may not have
> common ancestor, only NSObject. I want the objects to be something like
> 'Actors' - handling asynchronous (oneway) messages. To handle
> oneway messages
> withot creating my own mechanisms I am using  threads. In most operating
> systems, including linux, threads are expensive, but is there any other
> option?

Maybe there is... are these messages really "asynchronous"? What I mean, is
do you care when the get executed? i.e. do they have to be executed
simultaneously? If it would be ok for them to be executed during the next
runloop, I would suggest using NSRunLoop's
performSelector:target:argument:order:modes:.

> > Well I think all you have to do is use a different way of
> running the runloop in _establishThreadConnectionUsingParameters:
> >
> > use runUntilDate: providing a maximum timeout (at worst [NSDate
> distantFuture]) and this should return once all messages are
> processed and the thread shoud continue (and exit) normally. You
> might need some additional mechanism to keep it running until the
> first message has arrived, but I'm not sure on that.
> >
>
> Problem is, that there is no maximum timeout. One of the possible
> ways may be
> running the runloop with runUntilDate:some_near_furure in a loop
> and checking
> womehow, if it has to be terminated.

Make a note that runUntilDate only runs until the date OR until there are no
more input sources. So you could release the object after it returns. But

>
> >
> > Nicola pointed me to a very interesting uRL about
> Double-Checked-Locking. I'll forwarded privatly once I get back
> home. I can't access it from where I am right now.
> >
>

Cooming up!

Later,
Dave

PS: I'll look at your code, later. I've got to run right now.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]