Comment

Comment by RcouF1uZ4gsC

Looking at the code, it seems like it is more of a class project rather than a highly optimized library.

It is using mutexes, condition variables, and futures to write a pretty much textbook implementation of a thread pool.

However, there will be significant contention, as all the workers are reading from the same queue, and the submissions are going to the same queue.

There are not multiple queues with work-stealing which is I think a minimum for a production level version of something like this.

EDIT:

IIRC C++ Concurrency in Action by Anthony Williams has a nice discussion of the issues of building a C++ thread pool using the C++ standard library. It does address things like contention and work-stealing.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton