From af916ae24fa3d41adc9345eb335e2c3d201c04c3 Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Dec 04 2019 10:06:15 +0000 Subject: replace synfig::RWLock with Glib::Threads::RWLock --- diff --git a/synfig-core/src/synfig/CMakeLists.txt b/synfig-core/src/synfig/CMakeLists.txt index 17b05c9..2f78786 100644 --- a/synfig-core/src/synfig/CMakeLists.txt +++ b/synfig-core/src/synfig/CMakeLists.txt @@ -43,7 +43,6 @@ target_sources(synfig "${CMAKE_CURRENT_LIST_DIR}/loadcanvas.cpp" "${CMAKE_CURRENT_LIST_DIR}/main.cpp" "${CMAKE_CURRENT_LIST_DIR}/module.cpp" - "${CMAKE_CURRENT_LIST_DIR}/mutex.cpp" "${CMAKE_CURRENT_LIST_DIR}/node.cpp" "${CMAKE_CURRENT_LIST_DIR}/palette.cpp" "${CMAKE_CURRENT_LIST_DIR}/paramdesc.cpp" diff --git a/synfig-core/src/synfig/Makefile.am b/synfig-core/src/synfig/Makefile.am index 74298a6..2f1aa77 100644 --- a/synfig-core/src/synfig/Makefile.am +++ b/synfig-core/src/synfig/Makefile.am @@ -108,7 +108,6 @@ SYNFIGHEADERS = \ loadcanvas.h \ main.h \ module.h \ - mutex.h \ node.h \ palette.h \ paramdesc.h \ @@ -163,7 +162,6 @@ SYNFIGSOURCES = \ loadcanvas.cpp \ main.cpp \ module.cpp \ - mutex.cpp \ node.cpp \ palette.cpp \ paramdesc.cpp \ diff --git a/synfig-core/src/synfig/context.cpp b/synfig-core/src/synfig/context.cpp index 697c618..027a02e 100644 --- a/synfig-core/src/synfig/context.cpp +++ b/synfig-core/src/synfig/context.cpp @@ -107,7 +107,7 @@ IndependentContext::set_time(Time time, bool force)const Layer::Handle layer(*context); ++context; - RWLock::WriterLock lock(layer->get_rw_lock()); + Glib::Threads::RWLock::WriterLock lock(layer->get_rw_lock()); layer->set_time(context, time); } @@ -125,7 +125,7 @@ IndependentContext::load_resources(Time time, bool /*force*/)const Layer::Handle layer(*context); ++context; - //RWLock::WriterLock lock(layer->get_rw_lock()); + //Glib::Threads::RWLock::WriterLock lock(layer->get_rw_lock()); layer->load_resources(context, time); } @@ -146,7 +146,7 @@ IndependentContext::set_outline_grow(Real outline_grow)const Layer::Handle layer(*context); ++context; - RWLock::WriterLock lock(layer->get_rw_lock()); + Glib::Threads::RWLock::WriterLock lock(layer->get_rw_lock()); layer->set_outline_grow(context, outline_grow); } @@ -171,7 +171,7 @@ Context::get_color(const Point &pos)const // If this layer isn't defined, return alpha if((context)->empty()) return Color::alpha(); - RWLock::ReaderLock lock((*context)->get_rw_lock()); + Glib::Threads::RWLock::ReaderLock lock((*context)->get_rw_lock()); return (*context)->get_color(context.get_next(), pos); } @@ -197,7 +197,7 @@ Context::get_cairocolor(const Point &pos)const // If this layer isn't defined, return alpha if((context)->empty()) return CairoColor::alpha(); - RWLock::ReaderLock lock((*context)->get_rw_lock()); + Glib::Threads::RWLock::ReaderLock lock((*context)->get_rw_lock()); return (*context)->get_cairocolor(context.get_next(), pos); } @@ -364,7 +364,7 @@ Context::accelerated_render(Surface *surface,int quality, const RendDesc &rendde try { // lock the context for reading - RWLock::ReaderLock lock((*context)->get_rw_lock()); + Glib::Threads::RWLock::ReaderLock lock((*context)->get_rw_lock()); #ifdef SYNFIG_PROFILE_LAYERS //go down one layer :P depth++; @@ -466,7 +466,7 @@ Context::accelerated_cairorender(cairo_t *cr,int quality, const RendDesc &rendde try { // lock the context for reading - RWLock::ReaderLock lock((*context)->get_rw_lock()); + Glib::Threads::RWLock::ReaderLock lock((*context)->get_rw_lock()); #ifdef SYNFIG_PROFILE_LAYERS //go down one layer :P depth++; diff --git a/synfig-core/src/synfig/main.cpp b/synfig-core/src/synfig/main.cpp index 498e4ac..0cef8ec 100644 --- a/synfig-core/src/synfig/main.cpp +++ b/synfig-core/src/synfig/main.cpp @@ -74,8 +74,6 @@ #include "guid.h" -#include "mutex.h" - #include #ifdef HAVE_SIGNAL_H diff --git a/synfig-core/src/synfig/mutex.cpp b/synfig-core/src/synfig/mutex.cpp deleted file mode 100644 index 9dee831..0000000 --- a/synfig-core/src/synfig/mutex.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file mutex.cpp -** \brief Template File -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "mutex.h" - -#ifdef HAVE_LIBPTHREAD -#define USING_PTHREADS 1 -#else -#ifdef _WIN32 -#define USING_WIN32_THREADS 1 -#else -#error Need either libpthread of win32 threads -#endif -#endif - -#ifdef USING_WIN32_THREADS -#include -#endif - -#ifdef USING_PTHREADS -#include -#endif - -#endif - -/* === U S I N G =========================================================== */ - -//using namespace std; -//using namespace etl; -using namespace synfig; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -#ifdef USING_PTHREADS - -RWLock::RWLock() -{ - pthread_rwlock_t*const rwlock_ptr(new pthread_rwlock_t); - - pthread_rwlock_init(rwlock_ptr, NULL); - - blackbox=rwlock_ptr; -} - -RWLock::~RWLock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - pthread_rwlock_destroy(rwlock_ptr); - - delete rwlock_ptr; -} - -void -RWLock::reader_lock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - pthread_rwlock_rdlock(rwlock_ptr); -} - -void -RWLock::reader_unlock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - pthread_rwlock_unlock(rwlock_ptr); -} - -bool -RWLock::reader_trylock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - return !pthread_rwlock_tryrdlock(rwlock_ptr); -} - -void -RWLock::writer_lock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - pthread_rwlock_wrlock(rwlock_ptr); -} - -void -RWLock::writer_unlock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - pthread_rwlock_unlock(rwlock_ptr); -} - -bool -RWLock::writer_trylock() -{ - pthread_rwlock_t*const rwlock_ptr(static_cast(blackbox)); - - return !pthread_rwlock_trywrlock(rwlock_ptr); -} - -#endif - -#ifdef USING_WIN32_THREADS - -RWLock::RWLock() -{ -} - -RWLock::~RWLock() -{ -} - -void -RWLock::reader_lock() -{ -} - -void -RWLock::reader_unlock() -{ -} - -bool -RWLock::reader_trylock() -{ -} - -void -RWLock::writer_lock() -{ -} - -void -RWLock::writer_unlock() -{ -} - -bool -RWLock::writer_trylock() -{ -} - -#endif diff --git a/synfig-core/src/synfig/mutex.h b/synfig-core/src/synfig/mutex.h deleted file mode 100644 index d0ab6e7..0000000 --- a/synfig-core/src/synfig/mutex.h +++ /dev/null @@ -1,75 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file mutex.h -** \brief Template Header -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_MUTEX_H -#define __SYNFIG_MUTEX_H - -/* === H E A D E R S ======================================================= */ - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig { - -class RWLock -{ - void* blackbox; - -public: - - class ReaderLock - { - RWLock& rw_lock; - public: - ReaderLock(RWLock& x):rw_lock(x) { rw_lock.reader_lock(); } - ~ReaderLock() { rw_lock.reader_unlock(); } - }; - class WriterLock - { - RWLock& rw_lock; - public: - WriterLock(RWLock& x):rw_lock(x) { rw_lock.writer_lock(); } - ~WriterLock() { rw_lock.writer_unlock(); } - }; - - RWLock(); - ~RWLock(); - - void reader_lock(); - void reader_unlock(); - bool reader_trylock(); - - void writer_lock(); - void writer_unlock(); - bool writer_trylock(); -}; - -}; // END of namespace synfig - -/* === E N D =============================================================== */ - -#endif diff --git a/synfig-core/src/synfig/node.h b/synfig-core/src/synfig/node.h index 3efe400..03e54bb 100644 --- a/synfig-core/src/synfig/node.h +++ b/synfig-core/src/synfig/node.h @@ -38,7 +38,7 @@ #include #include "interpolation.h" #include -#include "mutex.h" +#include /* === M A C R O S ========================================================= */ @@ -156,8 +156,7 @@ private: mutable int time_last_changed_; //! \writeme - //! \see mutex.h - mutable RWLock rw_lock_; + mutable Glib::Threads::RWLock rw_lock_; //! Variable used to remember that a signal_deleted has been thrown bool deleting_; @@ -249,7 +248,7 @@ public: const time_set &get_times() const; //! Writeme! - RWLock& get_rw_lock()const { return rw_lock_; } + Glib::Threads::RWLock& get_rw_lock()const { return rw_lock_; } virtual String get_string()const = 0; protected: diff --git a/synfig-core/src/synfig/rendering/software/function/packedsurface.h b/synfig-core/src/synfig/rendering/software/function/packedsurface.h index 9d69653..ce5ed5a 100644 --- a/synfig-core/src/synfig/rendering/software/function/packedsurface.h +++ b/synfig-core/src/synfig/rendering/software/function/packedsurface.h @@ -31,7 +31,6 @@ #include #include -#include #include #include "../../primitive/contour.h" diff --git a/synfig-studio/src/gui/workarea.cpp b/synfig-studio/src/gui/workarea.cpp index 3f5b3f7..51c35fd 100644 --- a/synfig-studio/src/gui/workarea.cpp +++ b/synfig-studio/src/gui/workarea.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include