Loading...
Searching...
No Matches
juce_AudioWorkgroup.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class WorkgroupToken
{
public:
class TokenProvider;
using Erased = FixedSizeFunction<64, const TokenProvider*()>;
explicit WorkgroupToken (Erased e) : erased (std::move (e)) {}
WorkgroupToken() = default;
~WorkgroupToken() = default;
WorkgroupToken (const WorkgroupToken&) = delete;
WorkgroupToken (WorkgroupToken&&) noexcept = default;
WorkgroupToken& operator= (const WorkgroupToken&) = delete;
WorkgroupToken& operator= (WorkgroupToken&&) = default;
explicit operator bool() const { return getTokenProvider() != nullptr; }
[[nodiscard]] const TokenProvider* getTokenProvider() const { return erased != nullptr ? erased() : nullptr; }
void reset() { erased = nullptr; }
private:
Erased erased;
};
//==============================================================================
class AudioWorkgroup
{
public:
class WorkgroupProvider;
using Erased = FixedSizeFunction<64, const WorkgroupProvider*()>;
explicit AudioWorkgroup (Erased e) : erased (std::move (e)) {}
AudioWorkgroup (AudioWorkgroup&&) = default;
AudioWorkgroup& operator= (AudioWorkgroup&&) = default;
AudioWorkgroup (const AudioWorkgroup&);
AudioWorkgroup& operator= (const AudioWorkgroup& other)
{
AudioWorkgroup { other }.swap (*this);
return *this;
}
AudioWorkgroup() = default;
void join (WorkgroupToken& token) const;
bool operator== (const AudioWorkgroup& other) const;
bool operator!= (const AudioWorkgroup& other) const { return ! operator== (other); }
explicit operator bool() const;
void reset() { erased = nullptr; }
size_t getMaxParallelThreadCount() const;
private:
const WorkgroupProvider* getWorkgroupProvider() const { return erased != nullptr ? erased() : nullptr; }
void swap (AudioWorkgroup& other) noexcept { std::swap (other.erased, erased); }
Erased erased;
};
} // namespace juce
juce::AudioWorkgroup::operator!=
bool operator!=(const AudioWorkgroup &other) const
Definition juce_AudioWorkgroup.h:195
juce::AudioWorkgroup::AudioWorkgroup
AudioWorkgroup(Erased e)
Definition juce_AudioWorkgroup.h:154
juce::AudioWorkgroup::reset
void reset()
Definition juce_AudioWorkgroup.h:204
juce::AudioWorkgroup::operator=
AudioWorkgroup & operator=(AudioWorkgroup &&)=default
juce::AudioWorkgroup::AudioWorkgroup
AudioWorkgroup(AudioWorkgroup &&)=default
juce::AudioWorkgroup::getMaxParallelThreadCount
size_t getMaxParallelThreadCount() const
Definition juce_AudioWorkgroup.cpp:207
juce::AudioWorkgroup::AudioWorkgroup
AudioWorkgroup()=default
juce::AudioWorkgroup::operator==
bool operator==(const AudioWorkgroup &other) const
Definition juce_AudioWorkgroup.cpp:187
juce::AudioWorkgroup::join
void join(WorkgroupToken &token) const
Definition juce_AudioWorkgroup.cpp:192
juce::AudioWorkgroup::Erased
FixedSizeFunction< 64, const WorkgroupProvider *()> Erased
Definition juce_AudioWorkgroup.h:148
juce::WorkgroupToken
Definition juce_AudioWorkgroup.h:36
juce::WorkgroupToken::WorkgroupToken
WorkgroupToken()=default
juce::WorkgroupToken::WorkgroupToken
WorkgroupToken(Erased e)
Definition juce_AudioWorkgroup.h:48
juce::WorkgroupToken::~WorkgroupToken
~WorkgroupToken()=default
juce::WorkgroupToken::reset
void reset()
Definition juce_AudioWorkgroup.h:86
juce::WorkgroupToken::getTokenProvider
const TokenProvider * getTokenProvider() const
Definition juce_AudioWorkgroup.h:80
juce::WorkgroupToken::Erased
FixedSizeFunction< 64, const TokenProvider *()> Erased
Definition juce_AudioWorkgroup.h:42
juce::WorkgroupToken::WorkgroupToken
WorkgroupToken(const WorkgroupToken &)=delete