mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-15 00:24:19 +00:00
APVTS: Make adding/removing listeners threadsafe
This commit is contained in:
parent
aad3667e17
commit
e7004e634c
1 changed files with 28 additions and 1 deletions
|
|
@ -186,8 +186,35 @@ private:
|
|||
parameter.setValueNotifyingHost (value);
|
||||
}
|
||||
|
||||
class LockedListeners
|
||||
{
|
||||
public:
|
||||
template <typename Fn>
|
||||
void call (Fn&& fn)
|
||||
{
|
||||
const CriticalSection::ScopedLockType lock (mutex);
|
||||
listeners.call (std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
void add (Listener* l)
|
||||
{
|
||||
const CriticalSection::ScopedLockType lock (mutex);
|
||||
listeners.add (l);
|
||||
}
|
||||
|
||||
void remove (Listener* l)
|
||||
{
|
||||
const CriticalSection::ScopedLockType lock (mutex);
|
||||
listeners.remove (l);
|
||||
}
|
||||
|
||||
private:
|
||||
CriticalSection mutex;
|
||||
ListenerList<Listener> listeners;
|
||||
};
|
||||
|
||||
RangedAudioParameter& parameter;
|
||||
ListenerList<Listener> listeners;
|
||||
LockedListeners listeners;
|
||||
std::atomic<float> unnormalisedValue { 0.0f };
|
||||
std::atomic<bool> needsUpdate { true }, listenersNeedCalling { true };
|
||||
bool ignoreParameterChangedCallbacks { false };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue