I’ve been reading up on how close to making this possible Juce is from reading the develop branch commits on workgroups, and in the individual comments of the threads found on the forum.
It seems that:
1: It’s possible to start a Juce::thread, in an AU plugin, and have it join a workgroup.
2: It’s NOT possible through Juce to get the workgroup reference so that a posix thread can join it, AU or not.
3: It is ALSO not possible to join a workgroup, from a non-AU plugin.
(FR: Thread-Priority vs Efficiency/Performance Cores - #62 by anthony-nicholls)
(Os_workgroup_join consistently returns EINVAL - Can't join Audio Workgroup - #10 by ChrisASpatial)
It would be fantastic if there was a - static(?) - method, querying a thread for the workgroup it is in, from within the audio processing callback. Then that information can be used to join other threads to the same workgroup. This would allow also VST3 plugins to support workgroups, not only AU. I haven’t found anything in the Apple documentation to suggest this is possible, but hopefully I’m missing something?
Meanwhile, a feature request for Juce: at least from within an AU plugin, can such a method be implemented, to give workgroup information without starting a thread, so that it can be passed into 3rd-party libraries which support apple workgroups?
I see in AudioProcessor there is:
/** This is called by the host when the thread workgroup context has changed.
This will only be called on the audio thread, so you can join the audio workgroup
in your implementation of this function.
You can use this workgroup id to synchronise any real-time threads you have.
Note: This is currently only called on Apple devices.
*/
virtual void audioWorkgroupContextChanged ([[maybe_unused]] const AudioWorkgroup& workgroup) {}
Anything along those lines, that can be queried as well (exposing the platform specific os_workgroup_t p_workgroup), and isn’t only a callback, would be very useful!