20#include "cello_sync.h"
21#include "cello_object.h"
26UpdateQueue::UpdateQueue (
Object& consumer, juce::Thread* thread)
34 const juce::ScopedLock lock { mutex };
35 return static_cast<int> (queue.size ());
50 juce::MemoryBlock block;
52 const juce::ScopedLock lock { mutex };
53 block = std::move (queue.front ());
59void UpdateQueue::pushUpdate (juce::MemoryBlock&& update)
63 const juce::ScopedLock lock { mutex };
64 queue.push_back (update);
66 if (destThread ==
nullptr)
67 juce::MessageManager::callAsync (
70 jassert (juce::MessageManager::existsAndIsCurrentThread ());
78 destThread->notify ();
82: UpdateQueue (consumer, thread)
83, juce::ValueTreeSynchroniser { producer }
86 jassert (
static_cast<juce::ValueTree
> (producer) !=
87 static_cast<juce::ValueTree
> (consumer));
90void Sync::stateChanged (
const void* encodedChange,
size_t encodedChangeSize)
92 pushUpdate (juce::MemoryBlock (encodedChange, encodedChangeSize));
98#include "test/test_cello_sync.inl"
Definition cello_object.h:34
Sync(Object &producer, Object &consumer, juce::Thread *thread)
Construct a new Sync object.
Definition cello_sync.cpp:81
void performAllUpdates()
Execute each of the updates that are ready.
Definition cello_sync.cpp:38
int getPendingUpdateCount() const
Definition cello_sync.cpp:32
void performNextUpdate()
Pop the next event from the queue and apply the change to the destination value tree.
Definition cello_sync.cpp:44