Boost logo

Boost :

From: Roland (roland.schwarz_at_[hidden])
Date: 2004-08-06 09:11:03

Dear Mike,

could you please give me the reasoning why the cleanup handlers
that are specified in at_thread_exit must be serialized?

It turns out that this is caused by a mutex located in on_thread_exit.
Essentially this prohibits more than an exit handler chain to run at the same
time. While there might be sound reasons for this I'd like to know

How did I run into this:

I wanted to bind the lifetime of a second thread to the one
who started it. So I did soemthing like:

void start(void) {

if (!at_thread_exit(stop))
    syslog_thrd = new cthread::cancelable_thread(&syslog_run);


The stop function beeing declared as:
void stop(void) {
        if (syslog_thrd) {
                delete syslog_thrd;
                syslog_thrd = 0;

When my first thread is exiting now, the stop is getting called properly.
However my cancel causes the thread to exit (calling into its exit handler chain
in turn). This will of course cause deadlock (altough in an non obvious way)
since stop also has been called from the exit handler chain. The thread
cannot be joined because it does not really end. You see?

Perhaps you even can suggest another solution to my problem?


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