3 ms·
The thread pool approach allows you to exploit much finer grain parallelism than explicitly fork/joining your own threads. So, an application that makes good us
by scott_s 17y ago
The thread pool approach allows you to exploit much finer grain parallelism than explicitly fork/joining your own threads. So, an application that makes good use of this would probably have hundreds, if not thousands, of discrete work tasks (which I normally call "units of work," but Apple calls "blocks.")
What a thread pool infrastructure buys us is the separation of tasks (the bundle of information passed around the queues) from their execution context (in this case, a kernel thread). It puts a level of abstraction between what is executed and how that's executed.
At the risk of belaboring a point, this is an old idea - this is traditional multithreading. Java has a library for doing it, as does C++ (in Boost). A library for this kind of parallelism was, in fact, the first C++ library, written by Stroustrup. Even the Linux kernel uses this technique internally (by which I mean it's not exposed to applications at the user level). Cilk (the MIT project that spawned the company Cilk Arts which was recently acquired by Intel) is probably the best known example of providing language-level abstractions for this technique. (I reccomend their paper "The Implemention of the Cilk-5 Multithreaded Language": http://supertech.csail.mit.edu/papers/cilk5.pdf http://supertech.csail.mit.edu/papers/cilk5.pdf)
By pointing out that this is an old idea, I don't mean to denigrate what Apple has done. Execution matters, and from the looks of it, they've executed this well - they've got something working at the language and kernel level, which is non-trivial.