Boost logo

Boost Users :

Subject: Re: [Boost-users] [threadpool] Using with Boost.Bind
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-10-14 15:46:51


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 ) ) )


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