diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index 3cde7629bf..818fbf2219 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -64,7 +64,7 @@ MidiTracer::MidiTracer () , collect_button (_("Enabled")) , delta_time_button (_("Delta times")) { - g_atomic_int_set (&_update_queued, 0); + _update_queued.store (0); std::string portname (string_compose(X_("x-MIDI-tracer-%1"), ++window_count)); std::shared_ptr port = AudioEngine::instance()->register_input_port (DataType::MIDI, portname, false, PortFlags (IsInput | Hidden | IsTerminal)); @@ -511,7 +511,8 @@ MidiTracer::tracer (Parser&, MIDI::byte* msg, size_t len, samplecnt_t now) fifo.write (&buf, 1); - if (g_atomic_int_compare_and_exchange (&_update_queued, 0, 1)) { + int canderef (0); + if (_update_queued.compare_exchange_strong (canderef, 1)) { gui_context()->call_slot (invalidator (*this), boost::bind (&MidiTracer::update, this)); } } @@ -520,7 +521,7 @@ void MidiTracer::update () { bool updated = false; - g_atomic_int_set (&_update_queued, 0); + _update_queued.store (0); RefPtr buf (text.get_buffer()); diff --git a/gtk2_ardour/midi_tracer.h b/gtk2_ardour/midi_tracer.h index 6bb6abc281..775ff9cef9 100644 --- a/gtk2_ardour/midi_tracer.h +++ b/gtk2_ardour/midi_tracer.h @@ -22,6 +22,8 @@ #ifndef __ardour_gtk_midi_tracer_h__ #define __ardour_gtk_midi_tracer_h__ +#include + #include #include #include @@ -35,7 +37,6 @@ #include "pbd/signals.h" #include "pbd/ringbuffer.h" #include "pbd/pool.h" -#include "pbd/g_atomic_compat.h" #include "midi++/types.h" #include "ardour_window.h" @@ -75,7 +76,7 @@ private: * 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. */ - GATOMIC_QUAL gint _update_queued; + std::atomic _update_queued; PBD::RingBuffer fifo; PBD::Pool buffer_pool; diff --git a/gtk2_ardour/public_editor.cc b/gtk2_ardour/public_editor.cc index 120241e4a8..698d1bbb75 100644 --- a/gtk2_ardour/public_editor.cc +++ b/gtk2_ardour/public_editor.cc @@ -36,7 +36,7 @@ ARDOUR::DataType PublicEditor::pbdid_dragged_dt = ARDOUR::DataType::NIL; PublicEditor::PublicEditor (Gtk::Widget& content) : Tabbable (content, _("Editor"), X_("editor")) { - g_atomic_int_set (&_suspend_route_redisplay_counter, 0); + _suspend_route_redisplay_counter.store (0); } PublicEditor::~PublicEditor() diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 80f9508bdd..a833e3566d 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -32,6 +32,7 @@ #include "gtk2ardour-config.h" #endif +#include #include #include @@ -44,7 +45,6 @@ #include #include "pbd/statefuldestructible.h" -#include "pbd/g_atomic_compat.h" #include "temporal/beats.h" @@ -585,18 +585,18 @@ protected: virtual void resume_route_redisplay () = 0; virtual void _commit_tempo_map_edit (Temporal::TempoMap::WritableSharedPtr&, bool with_update) = 0; - GATOMIC_QUAL gint _suspend_route_redisplay_counter; + std::atomic _suspend_route_redisplay_counter; }; class DisplaySuspender { public: DisplaySuspender() { - if (g_atomic_int_add (&PublicEditor::instance()._suspend_route_redisplay_counter, 1) == 0) { + if (PublicEditor::instance()._suspend_route_redisplay_counter.fetch_add (1) == 0) { PublicEditor::instance().suspend_route_redisplay (); } } ~DisplaySuspender () { - if (g_atomic_int_dec_and_test (&PublicEditor::instance()._suspend_route_redisplay_counter)) { + if (PBD::atomic_dec_and_test (PublicEditor::instance()._suspend_route_redisplay_counter)) { PublicEditor::instance().resume_route_redisplay (); } } diff --git a/gtk2_ardour/timers.cc b/gtk2_ardour/timers.cc index e9218542a1..749962ad92 100644 --- a/gtk2_ardour/timers.cc +++ b/gtk2_ardour/timers.cc @@ -17,12 +17,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include "timers.h" +#include "pbd/atomic.h" #include "pbd/timer.h" #include "pbd/debug.h" #include "pbd/compose.h" -#include "pbd/g_atomic_compat.h" #include "debug.h" @@ -89,7 +91,7 @@ public: , super_rapid(40) , fps(40) { - g_atomic_int_set (&_suspend_counter, 0); + _suspend_counter.store (0); #ifndef NDEBUG second.connect (sigc::mem_fun (*this, &UITimers::on_second_timer)); #endif @@ -101,7 +103,7 @@ public: StandardTimer super_rapid; StandardTimer fps; - GATOMIC_QUAL gint _suspend_counter; + std::atomic _suspend_counter; #ifndef NDEBUG std::vector rapid_eps_count; @@ -213,7 +215,7 @@ fps_connect(const sigc::slot& slot) TimerSuspender::TimerSuspender () { - if (g_atomic_int_add (&get_timers()._suspend_counter, 1) == 0) { + if (get_timers()._suspend_counter.fetch_add (1) == 0) { get_timers().rapid.suspend(); get_timers().super_rapid.suspend(); get_timers().fps.suspend(); @@ -222,7 +224,7 @@ TimerSuspender::TimerSuspender () TimerSuspender::~TimerSuspender () { - if (g_atomic_int_dec_and_test (&get_timers()._suspend_counter)) { + if (PBD::atomic_dec_and_test (get_timers()._suspend_counter)) { get_timers().rapid.resume(); get_timers().super_rapid.resume(); get_timers().fps.resume();