Boost logo

Boost Users :

Subject: Re: [Boost-users] boost thread with class
From: Philipp Kraus (philipp.kraus_at_[hidden])
Date: 2012-12-30 13:20:33


Am 30.12.2012 um 12:53 schrieb Szymon Gatner:

> Hi Philip,
>
> 2012/12/30 Philipp Kraus <philipp.kraus_at_[hidden]>:
>
>>
>> Which structure must be implementated for the class myThread and from which class must be derived?
>>
>
> no need for derivation. Just implement operator() for your class like so:
>
> class myThread {
> public
> some methods
>
> void operator()()
> {
> // this will run in new thread
> }
>
> private
> some properties
> }

I get with this use compiler errors, this code

 boost::thread_group l_group;
for(std::size_t i=0; i < 5; ++i)
       l_group( myThread() );
l_group.join_all();

shows: error: no match for call to '(boost::thread_group) (myThread)'

on the loop line I have tested

l_group( boost::thread(myThread) );

and creates the error:

error: no match for call to '(boost::thread_group) (boost::thread)

In my class "myThread" I have a overloaded public method: void operator() (void);

How can I fix the error?

Thanks

Phil


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