Boost logo

Boost :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-02-22 10:36:41


--- In boost_at_y..., Markus Schöpflin <markus.schoepflin_at_g...> wrote:
> Hi all,
>
> the example at the end of the mutex documentation doesn't compile.
The problem is the line thrds.create_thread(&change_count, 0). This
won't work because create_thread() only takes the address of the
thread function as an argument. This can easily be fixed by removing
the second argument as it is not needed.

Thanks. I'm not sure how this one slipped through, but I'll correct
it in CVS ASAP. (This will take longer then the other changes
reported today since I'm overhauling the documentation.)

> As another question, how do I pass an argument to the thread
function when using thread_group::create_thread()?

As member data of a function object. The easiest way to do this
would be to use Boost.Bind.

void foo(int i)
{
}

boost::thread_group grp;
grp.create_thread(boost::bind(&foo, 10));

Bill Kempf


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