[PATCH] D48115: Make ThreadPool support running tasks that return values
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 21:00:24 PDT 2018
zturner created this revision.
zturner added reviewers: labath, dblaikie, davide.
Herald added a subscriber: hiraditya.
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.
https://reviews.llvm.org/D48115
Files:
llvm/include/llvm/Support/ThreadPool.h
llvm/lib/Support/ThreadPool.cpp
llvm/unittests/Support/ThreadPool.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48115.151097.patch
Type: text/x-patch
Size: 5796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180613/aca8d811/attachment.bin>
More information about the llvm-commits
mailing list