Boost logo

Boost Users :

From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2008-06-17 08:58:00


Matthias Vallentin <vallentin_at_[hidden]> writes:

> I am having issues with boost::thread::interrupt(). As far as I
> understood, calling this function will throw an exception in the
> corresponding thread. How can deal with blocking functions, such as a
> calls to accept() or when a thread is waiting on a condition variable
> to change? Basically the thread blocks somewhere in a while (true) loop.
>
> Injecting interruption points manually with
> boost::this_thread::interruption_point() does not seem to help here
> either. boost::thread::interrupt() (or interrupt_all in a thread_group),
> simply does not return.

boost::thread::interrupt() calls the interrupted thread to throw an
exception when it next reaches an interruption point with interruption
enabled. Interruption points are boost::this_thread::sleep,
boost::this_thread::interruption_point, boost::thread::join,
boost::condition_variable::wait and timed_ variants.

See
http://www.justsoftwaresolutions.co.uk/threading/thread-interruption-in-boost-thread-library.html

boost::thread::interrupt() should return almost immediately: it does
not wait for the thread to be interrupted.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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