The goal of a ForkJoinDispatcher
is to provide a group of dedicated threads managed outside the CLR ThreadPool
that can be shared by many actors / callers to concurrently. In an ideal world, the CLR would provide us with a way of creating instances of ThreadPool
and we would happily wrap one of those inside the ForkJoinDispatcher
and call UnsafeQueueUserWorkItem(wc, null)
for each piece of asynchronous work we need done.
However, since this isn't the case - we have to build one. We need a way to manage multiple threads and have them cooperatively and efficiently peform queued work like the ThreadPool
would.