On concurrency models

I don’t particularly have the motivation to write a long post again, but I’m a bit vexed by this specific part and the trivial dismissal of existing solutions. Dedicating entire domains to each library is indeed terrible, but I’ve been proposing to use Thread.t pools on top of a single domain pool for a year and a half now. We have the one good abstraction and it’s called threads. All we need is to entirely forget about the bad abstraction named Domain.t, treat it (like Go does) as an implementation detail, just like a CPU core, and provide libraries with:

val pool_size : unit -> int

val spawn_on : int -> (unit -> 'a) -> 'a Thread.t

and that’s it. That’s all you need. I have an implementation of that in moonpool, but it really should belong in the stdlib.

5 Likes