|
Boost : |
Subject: Re: [boost] [future William proposal] packaged_task do notacceptboost::ref of a nullary functor
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-01-05 15:28:18
"vicente.botet" <vicente.botet_at_[hidden]> writes:
> ----- Original Message -----
> From: "Anthony Williams" <anthony.ajw_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Monday, January 05, 2009 12:49 PM
> Subject: Re: [boost] [future William proposal] packaged_task do notacceptboost::ref of a nullary functor
>
>
>>
>> "vicente.botet" <vicente.botet_at_[hidden]> writes:
>>
>>> From: "vicente.botet" <vicente.botet_at_[hidden]>
>>
>>>> packaged_task do not accept boost::ref to nullary functions while
>>>> thread allows it. Shouldn't packaged_task > accept them? How can
>>>> the user workaround this issue? How thread solved this issue?
>>>
>>> I have found a workaround. Instead of
>>> boost::packaged_task<unsigned > tsk(boost::ref(f));
>>> I use
>>> boost::packaged_task<unsigned> tsk(boost::bind(boost::ref(f)));
>>>
>>> Is this the correct way?
>>
>> That's essentially what Boost.Thread does.
>
> Given the prototypes:
> template<typename F> explicit thread(F func);
>
> template <class F> explicit packaged_task(F const& f):
>
> Shouldn't the prototype of packaged_task be
> template <class F>
> explicit packaged_task(F f):
>
> Shouldn't boost::thread(boost::ref(f)); fail or
> boost::packaged_task<unsigned> tsk(boost::ref(f)); succeed?
>
> What is the reason to make them different?
Hmm. I'm not sure what the difference is with a plain
ref(f). Boost.thread uses bind<void>(f,args) when you specify args in
the constructor, but doesn't do anything for a plain function. I don't
know why it wouldn't work with packaged_task, but I haven't tried it.
I'll investigate.
Anthony
-- Anthony Williams Author of C++ Concurrency in Action | http://www.manning.com/williams Custom Software Development | http://www.justsoftwaresolutions.co.uk Just Software Solutions Ltd, Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk