Anthony Williams skrev:
Christian Larsen
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