, autoscroll (true)
, show_hex (true)
, collect (true)
- , update_queued (false)
+ , _update_queued (0)
, fifo (1024)
, buffer_pool ("miditracer", buffer_size, 1024) // 1024 256 byte buffers
, autoscroll_button (_("Auto-Scroll"))
fifo.write (&buf, 1);
- if (!update_queued) {
+ if (g_atomic_int_get (&_update_queued) == 0) {
gui_context()->call_slot (invalidator (*this), boost::bind (&MidiTracer::update, this));
- update_queued = true;
+ g_atomic_int_inc (&_update_queued);
}
}
MidiTracer::update ()
{
bool updated = false;
- update_queued = false;
+ g_atomic_int_dec_and_test (&_update_queued);
RefPtr<TextBuffer> buf (text.get_buffer());
bool autoscroll;
bool show_hex;
bool collect;
- volatile bool update_queued;
+
+ /** Incremented when an update is requested, decremented when one is handled; hence
+ * equal to 0 when an update is not queued. May temporarily be negative if a
+ * update is handled before it was noted that it had just been queued.
+ */
+ volatile gint _update_queued;
+
RingBuffer<char *> fifo;
Pool buffer_pool;
static const size_t buffer_size = 256;