|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2007-06-20 09:37:25
"Stephen Cossgrove" <scossgrove_at_[hidden]> writes:
> Hi, I am new to boost threads I have compiled both the 1.33 and 1.34 boost
> libraries and am getting the same error on both.
>
> Every time I run the program I get the "boost::bad_weak_ptr" error being
> caught in the Start function of the Boost Thread Class.
>
> Can anyone tell me what I am doing wrong?
You're misusing shared_from_this --- this only works if the object is owned by
a shared_ptr. You're creating your BoostThread object on the stack so it is
not owned by a shared_ptr and shared_from_this will throw bad_weak_ptr.
Anthony
-- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL