Boost logo

Boost :

From: Tim Laplaca (tlaplaca_at_[hidden])
Date: 2004-11-23 15:20:46


Thanks, it turns out I don't need to object class so I dropped it.

Tim

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Monday, November 22, 2004 5:57 PM
To: boost_at_[hidden]
Subject: Re: [boost] boost.thread : Can one create a thread with
anobjectmember function?

Tim Laplaca wrote:
> boost::thread_group thrds;
>
> objclass * objthread;
>
>
>
> objthread = new objclass;
>
> thrds.create_thread( (objthread->p) );

Do this instead:

    boost::shared_ptr<objclass> objthread( new objclass );
    thrds.create_thread( boost::bind( &objclass::dowork, objthread ) );

Even better, drop the objclass entirely and do this:

    void dowork( int tid, string valtwo )
    {
        // do work
    }

    thrds.create_thread( boost::bind( dowork, my_thread_id, my_valtwo )
);

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk