[PATCH] D126815: [llvm] [Support] [Debuginfod] waitQueueSize for ThreadPool

Daniel Thornburgh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 2 14:28:53 PDT 2022


mysterymath added a comment.

In D126815#3554505 <https://reviews.llvm.org/D126815#3554505>, @mehdi_amini wrote:

> That seems like a very ad-hoc API to me, can you handle this in your client code? Some atomic counter that you manage in your tasks should do the trick just as well?

Originally the client code did have such counters; I suggested the change to ThreadPool in code review.

If the producer of `ThreadPool.async` calls runs too much faster than the threads can consume the requests, then the size of the queue is unbounded. With a regular producer/consumer queue, you could check the size before producing, but there wasn't any way to do this in ThreadPool. Maintaining counters in the client is akin to keeping track of the queue size outside of the queue, which seems kludgey.

The suggestion was just for some kind of feedback mechanism from ThreadPool to callers; I don't have any strong opinions about the specifics of the API. Does a cleaner API come to mind? Even a `size()` method would probably work for this use case, since the producer is single-threaded.


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

https://reviews.llvm.org/D126815



More information about the llvm-commits mailing list