|
Boost : |
Subject: [boost] [thread] shouldn't at_thread_exit work on the main thread?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-11-10 11:34:13
Hi,
in the following example mycallable1 is not called at exit of the main
thread. Shouldn't at_thread_exit work on the main thread?
What is wrong?
Best,
Vicente
#include <boost/thread.hpp>
#include <iostream>
struct mycallable1
{
void operator()() const {
std::cout << "mycallable1" << std::endl;
};
};
struct mycallable2
{
void operator()() const {
std::cout << "mycallable2" << std::endl;
};
};
void my_thread() {
std::cout << "my_thread" << std::endl;
mycallable1 x;
boost::this_thread::at_thread_exit(x);
}
int main() {
mycallable2 x;
boost::this_thread::at_thread_exit(x);
boost::thread th(my_thread);
th.join();
return 0;
}
Output:
my_thread
mycallable1
EXIT STATUS: 0
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk