On 24 Jun 2015 4:48 pm, "Niall Douglas"
On 24 Jun 2015 at 16:30, Neil Groves wrote:
There is no reason for a packaged task implementation to be more heavy weight than a promise. If the packaged task is [](T x) { return x; }
then
it is also semantically equivalent to promise<T>, just in a nicer interface. Bonus points it works beautifully with ASIO without any explicit support from ASIO itself.
I think this is a very important point. Of course the interaction is better with most existing code bases of which ASIO is merely one (important) example. It is clear that in at least some cases the packaged task implementation need not add overhead. Does anyone have any examples where one needs the additional abstraction for optimal performance?
Yes: https://boostgsoc13.github.io/boost.afio/doc/html/afio/reference/class es/enqueued_task_r___.html
std::packaged_task has a very unhelpful design for real world programming. The ability to extract its its internally held promise, and optionally set it early within the task is exactly what afio::enqueued_task does.
A Packaged task is for all intent and purposes a promise. How exactly would you use the underlying promise and in which scenarios? -- gpd