[PATCH] D114183: [ThreadPool] Add template argument for future result type.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 19 12:44:10 PST 2021


fhahn added a comment.

In D114183#3143037 <https://reviews.llvm.org/D114183#3143037>, @Meinersbur wrote:

> In D114183#3142329 <https://reviews.llvm.org/D114183#3142329>, @fhahn wrote:
>
>> I tried using `void` with both `TaskTy` and `PackagedTaskTy`, but both resulted in build errors when sharing the Future.
>
> What were thoise build errors?

Variants of

  llvm/include/llvm/Support/ThreadPool.h:184:12: error: no viable conversion from returned value of type 'shared_future<void>' to function return type 'shared_future<llvm::SmallString<0>>'
      return Future.share();
             ^~~~~~~~~~~~~~



> Implementing a non-templated ThreadPool should be possible, as demonstrated here <https://github.com/cbraley/threadpool/blob/master/src/thread_pool.h>.

I think the issue is that LLVM's `ThreadPool` uses `std::packaged_task` to store the task and extract the future, and the type used for the future depends on the type for the packaged_task, which in turn depends on the type of `Task`.

Are you suggesting adjusting the way we package stuff in LLVM's `ThreadPool` so the packaged task types do not depend on the result type of the packaged function? I think that should be an feasible alternative.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114183/new/

https://reviews.llvm.org/D114183



More information about the llvm-commits mailing list