Boost logo

Boost Users :

Subject: Re: [Boost-users] [statechart] Question about do activities
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2009-04-22 05:11:34


Hi Bill

>I see that I'm way behind the times on boost::thread - I hadn't realized
> that cancellation had been added to it.

Interruption has been added to it, which is not what I had in mind with
cancellation. The former only allows to "stop" a thread at predefined points
(usually when the thread is waiting on a lock or a condition variable, etc.
The latter allows to "stop" a thread anywhere (even when it is executing a
while (true) {} loop).

In order to be useful for the general case, both actions must lead to an
exception being thrown in the target thread. An exception is required so
that acquired resources can be cleaned up correctly, which is why I put the
word stop in quotes above. The thread isn't really stopped immediately, it's
just instructed to start cleaning up as soon as possible.

> So, I'll rephrase the question - from the point of view of
> boost::statechart, is there a reason to prefer cancellation over some
> other
> means of stopping a thread, like calling a stop() function and then
> join()?

Boost.Thread doesn't offer stop(). Which threading API do you have in mind?

Regards,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net