Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2007-11-14 08:12:06

On Wed, 14 Nov 2007 10:51:40 +0000, Anthony Williams wrote:

> It's a little messy, but
> try
> {
> this_thread::interruption_point();
> }
> catch(thread_interrupted const&)
> {}
> does the trick. You could easily wrap it in a function. However, your
> code might be interrupted again straight away, so it's not 100%
> reliable.
> Why do you need this?

Lets say thread A is running, and not at an interruptable point (lock,
condition, etc. and its doing some long-running task that will not hit an
interruptable point. At some point during this task, I might check
thread->interruption_requested() to see if someone has requested an
interrupt to break my out of my current task. If this happens, I want to
handle that interruption a specific way. But because I now KNOW that the
interruptoin has been requested, and I can take appropriate action, I
need to clear the interrupt, because I have now handled it. Which, by
the way, may mean ignoring it (which your above code does).

But the above code would work, just putting in my own interruption points
will work to resolve this I think.

PreZ :)

Boost list run by bdawes at, gregod at, cpdaniel at, john at