Boost logo

Boost Users :

From: Christian Larsen (contact_at_[hidden])
Date: 2008-08-13 11:35:15


Anthony Williams skrev:
> Christian Larsen <contact_at_[hidden]> writes:
[snip]
>> My question is whether there is a
>> smarter way to reset the interruption request (if any) than this:
>>
>> try
>> {
>> boost::this_thread::interruption_point();
>> }
>> catch (boost::thread_interrupted&)
>> {
>> // ignore
>> }
[snip]
>
> That's essentially the only way to do it, but if interruption is
> disabled, even that won't work.

Ok, thanks for the reply.

Would there be any chance that a function for this would be added? I
mean, it doesn't feel right to throw and catch an exception for
controlling program flow (haven't benchmarked, but it has to be more
expensive than flipping a flag). Couldn't a reset functionality easily
be added?

In the specific situation where I'm using this, I have a thread which
sleeps in the background, but wakes up when it's assigned a task. It
runs the task to completion (tasks should be interruptible using
thread::interrupt) and then falls back to sleep waiting for another task.

What I need to make sure is that a call to interrupt while the the
thread is sleeping waiting on a condition variable (at this point
interruption _is_ disabled) is forgotten once a new task has arrived,
such that the new task (interruptible) will run regardless of earlier
interruptions.

Best regards,
Christian


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