Closed ltwardus closed 11 years ago
I like this. If only there was a way to move-capture then one could even avoid the shared_ptr.
Well, i was messing with something like:
std::packaged_task<Result()> task(callable);
...
tasks_.push_back(std::bind([](std::packaged_task<Result()> &&task){task();}, std::move(task)));
...
, but with no luck and at the moment it already looks too weird and in my opinion is complicating things more than it's needed :)
I've simplified the enqueue method, now the additional classes are not needed and the container is
std::deque<std::function<void()>>
: