AMDG Jason Cipriani wrote:
Hi, I'm new to boost. I'm using it for the shared_ptr implementation. I have a usage question. On Windows, a thread function takes a void* parameter. If I have a shared_ptr to an object, what's the correct way to pass that to a new thread? E.g.:
<snip>
Sorry if this is a stupid question, but the only thing I could think of was "(LPVOID)new shared_ptr(p)", but that means each thread must explicitly delete the new shared_ptr and that kind of defeats the purpose!
One solution would be to use Boost.Thread... Another would be to have the thread function immediately copy the shared_ptr to a local variable and delete the one on the heap. Finally, you could use enable_shared_from this, to allow a shared_ptr to be recovered from a raw pointer. In Christ, Steven Watanabe