Boost Users :
From: Ricky Corsi (riccardo.corsi_at_[hidden])
Date: 2005-05-28 04:12:19
I tried to modify the sample code from Bill Kempf for boost.thread,
listing 4 that I got at the following link
to embed the write function in a writeClass function-object.
That is a test because in a program I need to pass a function object to
one thread, and not a global function.
I simply wrote this code:
// for Debug
std::cout << "writerClass dtor" << std::endl;
void operator() ()
for (int n = 0; n < ITERS; ++n)
std::cout << "sending: "
<< n << std::endl;
and changed in the main()
--> boost::thread thrd2(&writer);
--> boost::thread thrd2((writerClass()));
Everything works the same, but I have the destructor of wirterClass
called 4 times, when constructing thrd2!!!
That's weird to me, but it's annoying because in my other program, the
dtor destroys some member data, and the program crashes because of it.
Why is the ~writerClass() called?
is there maybe some exception thrown??
how can I solve the problem?
if it can be useful, during the compilation I get a warning (MSVC 7.1),
but I read that it can be safely ignored:
non dll interface class "boost::noncopyable_::noncopyable"
used as a base for dll interface class "boost::mutex"
[...]\boost\noncopyable.hpp(22): see declaration of
[...]\boost\thread\mutex.hpp(33): see declaration of "boost::mutex"
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