Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-04-28 12:27:02


Ken Klose wrote:
> I've got a singleton object that is trying to run its operator()
> method in a separate thread, but I'm getting a segfault when I
> construct the thread object:
>
> PublishedListener::PublishedListener(string directory)
> {
> _thread = new thread(*this); // segfault here
> }

This line makes a copy of *this. It's very likely that this isn't what you
want. Use ref(*this) to store a reference, and consider disabling the copy
constructor and the assignment operator of the class.


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