Boost logo

Boost :

Subject: Re: [boost] [thread] 2 questions about thread interruption
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2016-04-18 17:50:43

2016-04-18 23:42 GMT+02:00 Andrzej Krzemienski <akrzemi1_at_[hidden]>:

> Hi,
> I have two questions connected to thread interruption in Boost.Thread.
> *1.* The docs say that interrupt_and_join_if_joinable is defined as
> follows:
> ```
> struct interrupt_and_join_if_joinable{
> void operator()(thread& t)
> {
> t.interrupt();
> if (t.joinable())
> {
> t.join();
> }
> }};
> ```

Sorry, let me continue with the question. Is there a reason why
t.interrupt() is called without checking if t is joinable? This looks
uncomfortable to me that I would be potentially calling interrupt() on a

*2.* When I make a call to this_thread::wait_for(), blocking for a long
time in thread t2, and the instant later I call t2.interrupt() from another
thread t1. Do I have to wait the long time until wait_for() stops blocking
t2, or does thread_interrupted get called 'immediately' after interrupt()
is called from t1?

*3.* Does the support for interruption points require the other
synchronization operations (like locks on mutexes) to be slower (in order
to monitor interruption requests)?


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