|
Boost Users : |
Subject: Re: [Boost-users] [threadpool] Using with Boost.Bind
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2011-10-15 11:59:49
On Fri, Oct 14, 2011 at 8:46 PM, Peter Dimov <pdimov_at_[hidden]> wrote:
> Robert Jones wrote:
> ...
>
>
> void task( int );
>>
>> vector<int> v;
>> v += 1,2,3,4,5,6,7,8,9;
>> pool my_pool;
>>
>> for_each( v.begin( ), v.end( ), bind( schedule, my_pool, _1 ) );
>>
>
> The easiest solution would be for you to define
>
> void my_schedule( pool & my_pool, int k )
> {
> schedule( pool, boost::bind( task, k ) );
> }
>
> and then use my_schedule above (you'll need ref(my_pool) though.)
>
> Or, you could bind &pool::schedule directly, without going via the schedule
> convenience wrapper:
>
> bind( &pool::schedule, &my_pool, protect( bind( task, _1 ) ) )
>
>
Hi Peter
Thanks for that - I very much prefer your second solution as it keeps it all
very local, and thanks
also for deciphering my gibberish which did of course completely fail to
mention 'task()'!
- Rob.
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