OpenShot Audio Library | OpenShotAudio 0.4.0
 
Loading...
Searching...
No Matches
juce_AudioWorkgroup.h
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
65 WorkgroupToken (WorkgroupToken&&) noexcept = default;
66
68 WorkgroupToken& operator= (const WorkgroupToken&) = delete;
69
70 WorkgroupToken& operator= (WorkgroupToken&&) = default;
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
bool operator!=(const AudioWorkgroup &other) const
AudioWorkgroup & operator=(AudioWorkgroup &&)=default
AudioWorkgroup(AudioWorkgroup &&)=default
size_t getMaxParallelThreadCount() const
AudioWorkgroup()=default
bool operator==(const AudioWorkgroup &other) const
void join(WorkgroupToken &token) const
FixedSizeFunction< 64, const WorkgroupProvider *()> Erased
WorkgroupToken()=default
~WorkgroupToken()=default
const TokenProvider * getTokenProvider() const
FixedSizeFunction< 64, const TokenProvider *()> Erased
WorkgroupToken(const WorkgroupToken &)=delete