|
Boost Users : |
From: STenyaK (Bruno Gonzalez) (stenyak_at_[hidden])
Date: 2007-12-19 12:24:59
On 12/19/07, Andrew Holden <aholden_at_[hidden]> wrote:
> STenyaK (Bruno Gonzalez) [stenyak_at_[hidden]] wrote:
> > On 12/19/07, Andrew Holden <aholden_at_[hidden]> wrote:
> >> typedef shared_ptr<MyClass> pMyClass;
> >> void* MyClass::actionThread(void *objectPointer)
> >> {
> >> MyClass * _obj = static_cast<MyClass*>(objectPointer);
> >> pMyClass obj = _obj->shared_from_this();
> >> obj->action(false);
> >> }
> >>
> >> void MyClass::action(bool threaded)
> >> {
> >> if (threaded)
> >> {
> >> pthread_t tid;
> >> pthread_create(&tid, 0, actionThread, this)
sleep(1);
> >> } else {
> >> //TODO: actually perform the action
> >> }
> >> }
> >> ----------------------------
I'm still getting crashes. By adding that sleep sentence i seem to
prevent them (or most of them).
So i guess i have to add a wait right there, in order to make sure
that _obj still exists when trying to get its shared_from_this?
-- Saludos, Bruno González _______________________________________________ Msn/Jabber: stenyak AT gmail.com ICQ: 153709484 http://www.stenyak.com
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