|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2007-10-12 11:07:49
> Hello list:
>
> I'm new new using boost library, I think it's great, really great... now
> the
> problem, I need to create a program that uses a class for executing 3
> threads, like this:
>
> class CLASSNAME
> {
> // thread functions
> void read();
> void write();
> void save();
>
> // main function
> void run( int param );
>
> // attributes
> };
>
> I just read the boost-doc once and once again but can't understand really
> the theory..., I'm using Debian GNU/Linux and compiling using
> Code::Blocks,
> when I write, for example:
>
> void CLASSNAME::run( int param )
> {
> // stuff here
> thread_group th_group = new thread_group;
> th_group->create_thread( &CLASSNAME::read ); // error here bad
> function
> prototype or s.th.
> }
>
> I get an error messaje, I can't tell now because I'm not in my own
> computer... any advice ?
&CLASSNAME::read gives you a member function pointer. This needs an object
to run against. You could use boost bind to pass "this" as the object:
th_group->create_thread( boost::bind(&CLASSNAME::read,this));
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