Boost logo

Boost :

From: Tim Laplaca (tlaplaca_at_[hidden])
Date: 2004-11-23 17:16:10


I assume I need to include some bind includes to get this to compile
(I'm getting "error: `bind' undeclared in namespace `boost'".

I see several includes in /usr/include/boost/bind. Which should I
include? None are obvious to me, like 'bind.hpp' would be.

Thanks,
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