previously ThreadPool could only execute tasks that did something, not tasks that returned values. We can improve this with a little bit of type erasure. The idea is that instead of queueing up packaged_task<void()>'s, we queue up unique_ptr<TaskBase>, where TaskBase is a base class that has an pure virtual execute() method. A templated derived class stores an appropriately typed package_task<T()>, which is run with execute() is called.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Yes, maybe not immediately, but it's one more step along the way of things I find I'm needing.
you could include cassert so it fits in nicely with the other c++ headers.