mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioWorkgroups: Add os_workgroup_max_parallel_threads support
This commit is contained in:
parent
387eea5f51
commit
70651f1c67
2 changed files with 22 additions and 0 deletions
|
|
@ -204,6 +204,21 @@ void AudioWorkgroup::join (WorkgroupToken& token) const
|
|||
token.reset();
|
||||
}
|
||||
|
||||
size_t AudioWorkgroup::getMaxParallelThreadCount() const
|
||||
{
|
||||
#if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE
|
||||
|
||||
if (@available (macos 11.0, ios 14.0, *))
|
||||
{
|
||||
if (auto wg = WorkgroupProvider::getWorkgroup (*this))
|
||||
return (size_t) os_workgroup_max_parallel_threads (wg, nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AudioWorkgroup::operator bool() const { return WorkgroupProvider::getWorkgroup (*this) != nullptr; }
|
||||
|
||||
#if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE
|
||||
|
|
|
|||
|
|
@ -203,6 +203,13 @@ public:
|
|||
*/
|
||||
void reset() { erased = nullptr; }
|
||||
|
||||
/** Returns the recommended maximum number of parallel threads that should join this workgroup.
|
||||
|
||||
This recommendation is based on the workgroup attributes and current hardware, but not on
|
||||
system load. On a very busy system, it may be more effective to use fewer parallel threads.
|
||||
*/
|
||||
size_t getMaxParallelThreadCount() const;
|
||||
|
||||
private:
|
||||
const WorkgroupProvider* getWorkgroupProvider() const { return erased != nullptr ? erased() : nullptr; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue