JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ThreadPriorities_native.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
27{
28 struct Entry
29 {
30 Thread::Priority priority;
31 int native;
32 };
33
34 #if JUCE_ANDROID
36 {
44 };
45 #endif
46
47 inline static constexpr Entry table[]
48 {
49 #if JUCE_ANDROID
50 { Thread::Priority::highest, AndroidThreadPriority::THREAD_PRIORITY_AUDIO },
51 { Thread::Priority::high, AndroidThreadPriority::THREAD_PRIORITY_FOREGROUND },
52 { Thread::Priority::normal, AndroidThreadPriority::THREAD_PRIORITY_DEFAULT },
53 { Thread::Priority::low, AndroidThreadPriority::THREAD_PRIORITY_BACKGROUND - 5 },
54 { Thread::Priority::background, AndroidThreadPriority::THREAD_PRIORITY_BACKGROUND },
55 #endif
56
57 #if JUCE_LINUX || JUCE_BSD
63 #endif
64
65 #if JUCE_MAC || JUCE_IOS
71 #endif
72
73 #if JUCE_WINDOWS
79 #endif
80 };
81
82 static_assert (std::size (table) == 5,
83 "The platform may be unsupported or there may be a priority entry missing.");
84
85 static Thread::Priority getJucePriority (const int value)
86 {
87 const auto iter = std::min_element (std::begin (table),
88 std::end (table),
89 [value] (const auto& a, const auto& b)
90 {
91 return std::abs (a.native - value) < std::abs (b.native - value);
92 });
93
94 jassert (iter != std::end (table));
95 return iter != std::end (table) ? iter->priority : Thread::Priority{};
96 }
97
98 static int getNativePriority (const Thread::Priority value)
99 {
100 const auto iter = std::find_if (std::begin (table),
101 std::end (table),
102 [value] (const auto& entry) { return entry.priority == value; });
103
104 jassert (iter != std::end (table));
105 return iter != std::end (table) ? iter->native : 0;
106 }
107};
108
109} // namespace juce
T begin(T... args)
Priority
The different runtime priorities of non-realtime threads.
Definition juce_Thread.h:54
@ low
Uses efficiency cores when possible.
@ high
Makes use of performance cores and higher clocks.
@ background
Restricted to efficiency cores on platforms that have them.
@ highest
The highest possible priority that isn't a dedicated realtime thread.
@ normal
The OS default.
T end(T... args)
T find_if(T... args)
#define jassert(expression)
Platform-independent assertion macro.
T min_element(T... args)
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
T size(T... args)