From 424d47a366535696897dec66810030651c148af8 Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Dec 06 2019 08:41:34 +0000 Subject: replace some deprecated Glib::[Threads::]Mutex with std::mutex --- diff --git a/synfig-core/src/synfig/debug/measure.cpp b/synfig-core/src/synfig/debug/measure.cpp index cf248ce..9497764 100644 --- a/synfig-core/src/synfig/debug/measure.cpp +++ b/synfig-core/src/synfig/debug/measure.cpp @@ -52,12 +52,12 @@ using namespace debug; /* === M E T H O D S ======================================================= */ -Glib::Threads::Mutex Measure::mutex; +std::mutex Measure::mutex; std::vector Measure::stack; String Measure::text; void Measure::init() { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); hide = !stack.empty() && stack.back()->hide_subs; hide_subs = hide_subs || hide; if (!hide) @@ -71,7 +71,7 @@ void Measure::init() { } Measure::~Measure() { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); long long dt = g_get_monotonic_time() - t; long long cpu_dt = clock() - cpu_t; diff --git a/synfig-core/src/synfig/debug/measure.h b/synfig-core/src/synfig/debug/measure.h index 940deef..12e8d86 100644 --- a/synfig-core/src/synfig/debug/measure.h +++ b/synfig-core/src/synfig/debug/measure.h @@ -29,7 +29,7 @@ #include -#include +#include #include @@ -46,7 +46,7 @@ namespace debug { class Measure { private: - static Glib::Threads::Mutex mutex; + static std::mutex mutex; static std::vector stack; static String text; diff --git a/synfig-core/src/synfig/rendering/opengl/internal/context.h b/synfig-core/src/synfig/rendering/opengl/internal/context.h index 2e7d112..d7d8e39 100644 --- a/synfig-core/src/synfig/rendering/opengl/internal/context.h +++ b/synfig-core/src/synfig/rendering/opengl/internal/context.h @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -97,7 +97,7 @@ public: }; private: - Glib::Threads::RecMutex rec_mutex; + std::recursive_mutex rec_mutex; Display *display; GLXFBConfig config; diff --git a/synfig-core/src/synfig/rendering/software/function/fft.cpp b/synfig-core/src/synfig/rendering/software/function/fft.cpp index 1dc8936..14282ca 100644 --- a/synfig-core/src/synfig/rendering/software/function/fft.cpp +++ b/synfig-core/src/synfig/rendering/software/function/fft.cpp @@ -33,7 +33,7 @@ #include //#include -#include +#include #include #include @@ -59,11 +59,11 @@ class software::FFT::Internal { public: static std::set counts; - static Glib::Mutex mutex; + static std::mutex mutex; }; std::set software::FFT::Internal::counts; -Glib::Mutex software::FFT::Internal::mutex; +std::mutex software::FFT::Internal::mutex; void software::FFT::initialize() @@ -118,7 +118,7 @@ software::FFT::fft(const Array &x, bool invert) iodim.os = x.stride; { - Glib::Mutex::Lock lock(Internal::mutex); + std::lock_guard lock(Internal::mutex); fftw_plan plan = fftw_plan_guru_dft( 1, &iodim, 0, NULL, (fftw_complex*)x.pointer, (fftw_complex*)x.pointer, @@ -153,7 +153,7 @@ software::FFT::fft2d(const Array &x, bool invert, bool do_rows, bool iodim[1].os = x.stride; { - Glib::Mutex::Lock lock(Internal::mutex); + std::lock_guard lock(Internal::mutex); fftw_plan plan; if (do_rows && do_cols) diff --git a/synfig-core/src/synfig/rendering/surface.cpp b/synfig-core/src/synfig/rendering/surface.cpp index 6c68716..8c2f73a 100644 --- a/synfig-core/src/synfig/rendering/surface.cpp +++ b/synfig-core/src/synfig/rendering/surface.cpp @@ -225,7 +225,7 @@ SurfaceResource::get_surface( if (!full && !rect.is_valid()) return Surface::Handle(); - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); if (width <= 0 || height <= 0) return Surface::Handle(); @@ -281,7 +281,7 @@ void SurfaceResource::create(int width, int height) { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); if (width > 0 && height > 0) { this->width = width; this->height = height; @@ -297,7 +297,7 @@ void SurfaceResource::assign(Surface::Handle surface) { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); for(Map::const_iterator i = surfaces.begin(); i != surfaces.end(); ++i) if (i->second == surface) @@ -320,7 +320,7 @@ void SurfaceResource::clear() { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); blank = true; surfaces.clear(); } @@ -329,7 +329,7 @@ void SurfaceResource::reset() { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); width = 0; height = 0; blank = true; diff --git a/synfig-core/src/synfig/rendering/surface.h b/synfig-core/src/synfig/rendering/surface.h index b709e2c..032b404 100644 --- a/synfig-core/src/synfig/rendering/surface.h +++ b/synfig-core/src/synfig/rendering/surface.h @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -330,7 +331,7 @@ private: bool blank; Map surfaces; - mutable Glib::Threads::Mutex mutex; + mutable std::mutex mutex; mutable Glib::Threads::RWLock rwlock; Surface::Handle get_surface( @@ -357,22 +358,22 @@ public: int get_id() const //!< helps to debug of renderer optimizers { return id; } int get_width() const - { Glib::Threads::Mutex::Lock lock(mutex); return width; } + { std::lock_guard lock(mutex); return width; } int get_height() const - { Glib::Threads::Mutex::Lock lock(mutex); return height; } + { std::lock_guard lock(mutex); return height; } VectorInt get_size() const - { Glib::Threads::Mutex::Lock lock(mutex); return VectorInt(width, height); } + { std::lock_guard lock(mutex); return VectorInt(width, height); } bool is_exists() const - { Glib::Threads::Mutex::Lock lock(mutex); return width > 0 && height > 0; } + { std::lock_guard lock(mutex); return width > 0 && height > 0; } bool is_blank() const - { Glib::Threads::Mutex::Lock lock(mutex); return blank; } + { std::lock_guard lock(mutex); return blank; } bool has_surface(const Surface::Token::Handle &token) const - { Glib::Threads::Mutex::Lock lock(mutex); return surfaces.count(token); } + { std::lock_guard lock(mutex); return surfaces.count(token); } template bool has_surface() const { return has_surface(T::token.handle()); } bool get_tokens(std::vector &outTokens) const { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); for(Map::const_iterator i = surfaces.begin(); i != surfaces.end(); ++i) outTokens.push_back(i->first); return !surfaces.empty(); diff --git a/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp b/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp index 76ab73b..0ebf256 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp +++ b/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp @@ -238,7 +238,7 @@ Renderer_Canvas::on_tile_finished(bool success, const Tile::Handle &tile) if (success && tile->surface) cairo_surface = convert(tile->surface, tile->rect.get_width(), tile->rect.get_height()); - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); --enqueued_tasks; @@ -267,7 +267,7 @@ Renderer_Canvas::on_post_tile_finished(const Tile::Handle &tile) int local_enqueued_tasks; Time time; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); time = tile->frame_id.time; if (visible_frames.count(tile->frame_id)) tile_visible = true; @@ -519,7 +519,7 @@ Renderer_Canvas::enqueue_render() rendering::Task::List events; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); String renderer_name = get_work_area()->get_renderer(); RectInt window_rect = get_work_area()->get_window_rect(); @@ -620,7 +620,7 @@ Renderer_Canvas::wait_render() { rendering::TaskEvent::List events; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); for(FrameList::const_iterator i = onion_frames.begin(); i != onion_frames.end(); ++i) { TileMap::const_iterator ii = tiles.find(i->id); if (ii != tiles.end()) @@ -639,7 +639,7 @@ Renderer_Canvas::clear_render() rendering::Task::List events; bool cleared = false; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); cleared = !tiles.empty(); for(TileMap::iterator i = tiles.begin(); i != tiles.end(); ++i) while(!i->second.empty()) { @@ -700,7 +700,7 @@ Renderer_Canvas::calc_frame_status(const FrameId &id, const RectInt &window_rect void Renderer_Canvas::get_render_status(StatusMap &out_map) { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); RectInt window_rect = get_work_area()->get_window_rect(); @@ -777,7 +777,7 @@ Renderer_Canvas::render_vfunc( empty_rects.push_back(previous_rect); { // merge all tiles into single surface - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); if (onion_frames.empty()) return; @@ -902,7 +902,7 @@ Renderer_Canvas::render_vfunc( Cairo::RefPtr Renderer_Canvas::get_thumb(const Time &time) { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); TileMap::const_iterator i = tiles.find( current_thumb.with_time(time) ); return i == tiles.end() || i->second.empty() || !*(i->second.begin()) ? Cairo::RefPtr() diff --git a/synfig-studio/src/gui/workarearenderer/renderer_canvas.h b/synfig-studio/src/gui/workarearenderer/renderer_canvas.h index d3e50bd..e3673e2 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_canvas.h +++ b/synfig-studio/src/gui/workarearenderer/renderer_canvas.h @@ -33,8 +33,6 @@ #include #include -#include - #include #include #include @@ -149,7 +147,7 @@ private: const int max_enqueued_tasks; //! controls access to fields: enqueued_tasks, tiles, onion_frames, visible_frames, current_frame, frame_duration, tiles_size - Glib::Threads::Mutex mutex; + std::mutex mutex; int enqueued_tasks;