This is indeed what I do with my current thread pool implementation.
What I could have is a lock free buffer pool with enough to handle all the concurrent thread to match the CLAP idiom.
That was my point and the API I use for my own thread poolmystran wrote: ↑Fri Dec 16, 2022 11:12 am I don't think there's a sane way to do this with the current API. As you say, knowing the number of threads in the pool and having sequential indexes for them that are passed to the task function would enable these kinds of schemes where tasks "borrow" per-thread resources.
With the current API the sane thing to do is just alloc per-voice, but I'd support revision of the API for these extra bits of information; implementation cost should be low, performance benefits should be real even if not necessarily huge and really the only downside is that it'd be a breaking change to API.