Boost logo

Boost :

Subject: [boost] [thread] 5351 interrupt a future get boost::unknown_exception
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-12-10 20:41:51


I have reached to compile the example with some variants. See the
attached file in

It seems the problem comes from the fact that packaged_task catch every

            void do_run()

and store it to rethrow in the wait() function using

                 if(rethrow&& exception)

As thread_interrupted doesn't inherits from std/boost::exception the
thrown exception is translated as boost::unknown_exception.

A solution could be to catch specifically thread_interrupted and store
this fact.

                 catch(thread_interrupted& it)

             void mark_interrupted_finish()
                 boost::lock_guard<boost::mutex> lock(mutex);

When wait is called, a test if the thread has been interrupted is done
so that the exception thread_interrupted is thrown.

                 if(rethrow && thread_was_interrupted)
                     throw boost::thread_interrupted();

The single problem I see is that the this new exception doesn't contains
from where the initial thread_interrupted was thrown.

Could the interested parties inspect the patch attached to and check it, please?
Is there something I forgot or a simple or more robust way to solve this
missing feature?


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