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_AudioWorkgroup.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
26//==============================================================================
36{
37public:
39 class TokenProvider;
40
42 using Erased = FixedSizeFunction<64, const TokenProvider*()>;
43
48 explicit WorkgroupToken (Erased e) : erased (std::move (e)) {}
49
55 WorkgroupToken() = default;
56
60 ~WorkgroupToken() = default;
61
63 WorkgroupToken (const WorkgroupToken&) = delete;
64
66
69
71
73 explicit operator bool() const { return getTokenProvider() != nullptr; }
74
80 [[nodiscard]] const TokenProvider* getTokenProvider() const { return erased != nullptr ? erased() : nullptr; }
81
86 void reset() { erased = nullptr; }
87
88private:
89 Erased erased;
90};
91
92//==============================================================================
142{
143public:
145 class WorkgroupProvider;
146
148 using Erased = FixedSizeFunction<64, const WorkgroupProvider*()>;
149
154 explicit AudioWorkgroup (Erased e) : erased (std::move (e)) {}
155
158
161
164
167 {
168 AudioWorkgroup { other }.swap (*this);
169 return *this;
170 }
171
173 AudioWorkgroup() = default;
174
189 void join (WorkgroupToken& token) const;
190
192 bool operator== (const AudioWorkgroup& other) const;
193
195 bool operator!= (const AudioWorkgroup& other) const { return ! operator== (other); }
196
198 explicit operator bool() const;
199
204 void reset() { erased = nullptr; }
205
211 size_t getMaxParallelThreadCount() const;
212
213private:
214 const WorkgroupProvider* getWorkgroupProvider() const { return erased != nullptr ? erased() : nullptr; }
215
216 void swap (AudioWorkgroup& other) noexcept { std::swap (other.erased, erased); }
217
218 Erased erased;
219};
220
221} // namespace juce
A handle to an audio workgroup, which is a collection of realtime threads working together to produce...
bool operator!=(const AudioWorkgroup &other) const
Inequality operator.
void reset()
Disengages this instance so that it no longer represents a workgroup.
AudioWorkgroup & operator=(AudioWorkgroup &&)=default
Move assignment operator.
AudioWorkgroup(AudioWorkgroup &&)=default
Move constructor.
size_t getMaxParallelThreadCount() const
Returns the recommended maximum number of parallel threads that should join this workgroup.
AudioWorkgroup()=default
Constructs a disengaged handle that does not represent any workgroup.
bool operator==(const AudioWorkgroup &other) const
Equality operator.
void join(WorkgroupToken &token) const
This method attempts to join the calling thread to this workgroup.
Created by AudioWorkgroup to join the calling thread to a workgroup.
~WorkgroupToken()=default
If the token joined the calling thread to a workgroup during construction, the destructor will cause ...
void reset()
If this token was engaged by joining a workgroup, leaves that workgroup and disengages the token.
const TokenProvider * getTokenProvider() const
The result of this function can be compared to nullptr to check whether the token successfully joined...
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 swap(T... args)