For WASM, this would lead to a compilation failure since WebAssembly threads need an allocator. Given that std.Thread.Pool.init() requires an allocator, why doesn’t it just pass it on?
You pass the allocator to Pool, but Pool is currently not using during the spawning of the worker threads.
I think @chung-leong is right, there’s no reason not the pass the pool allocator in the SpawnConfig parameter.
This should be a simple PR.
Yes, std.Thread.Pool.spawn takes care to pass the pool worker and the pool as parameter, the allocator is stored in the pool and used by worker to create and destroy a closure.
But if someone calls std.Thread.spawn directly, the thread is not associated with any pool and does not need an allocator.
But, as shown in the snippet, the Pool.init method is calling Thread.spawn directly, right? In order for this method to use the allocator, the pool would have to pass it in the SpawnConfig parameter.