diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-16 21:03:24 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-16 21:03:24 +0000 |
commit | 7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (patch) | |
tree | 99ec531924f6078534b100ab9d7696abce848099 /include/llvm/Support/ThreadPool.h | |
parent | 7ab83427af0f77b59941ceba41d509d7d097b065 (diff) |
Notes
Diffstat (limited to 'include/llvm/Support/ThreadPool.h')
-rw-r--r-- | include/llvm/Support/ThreadPool.h | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/include/llvm/Support/ThreadPool.h b/include/llvm/Support/ThreadPool.h index f0e3ffa0999c2..9ada946c6dae3 100644 --- a/include/llvm/Support/ThreadPool.h +++ b/include/llvm/Support/ThreadPool.h @@ -35,17 +35,8 @@ namespace llvm { /// for some work to become available. class ThreadPool { public: -#ifndef _MSC_VER - using VoidTy = void; using TaskTy = std::function<void()>; using PackagedTaskTy = std::packaged_task<void()>; -#else - // MSVC 2013 has a bug and can't use std::packaged_task<void()>; - // We force it to use bool(bool) instead. - using VoidTy = bool; - using TaskTy = std::function<bool(bool)>; - using PackagedTaskTy = std::packaged_task<bool(bool)>; -#endif /// Construct a pool with the number of core available on the system (or /// whatever the value returned by std::thread::hardware_concurrency() is). @@ -60,30 +51,17 @@ public: /// Asynchronous submission of a task to the pool. The returned future can be /// used to wait for the task to finish and is *non-blocking* on destruction. template <typename Function, typename... Args> - inline std::shared_future<VoidTy> async(Function &&F, Args &&... ArgList) { + inline std::shared_future<void> async(Function &&F, Args &&... ArgList) { auto Task = std::bind(std::forward<Function>(F), std::forward<Args>(ArgList)...); -#ifndef _MSC_VER return asyncImpl(std::move(Task)); -#else - // This lambda has to be marked mutable because MSVC 2013's std::bind call - // operator isn't const qualified. - return asyncImpl([Task](VoidTy) mutable -> VoidTy { - Task(); - return VoidTy(); - }); -#endif } /// Asynchronous submission of a task to the pool. The returned future can be /// used to wait for the task to finish and is *non-blocking* on destruction. template <typename Function> - inline std::shared_future<VoidTy> async(Function &&F) { -#ifndef _MSC_VER + inline std::shared_future<void> async(Function &&F) { return asyncImpl(std::forward<Function>(F)); -#else - return asyncImpl([F] (VoidTy) -> VoidTy { F(); return VoidTy(); }); -#endif } /// Blocking wait for all the threads to complete and the queue to be empty. @@ -93,7 +71,7 @@ public: private: /// Asynchronous submission of a task to the pool. The returned future can be /// used to wait for the task to finish and is *non-blocking* on destruction. - std::shared_future<VoidTy> asyncImpl(TaskTy F); + std::shared_future<void> asyncImpl(TaskTy F); /// Threads in flight std::vector<llvm::thread> Threads; |