diff --git a/src/addons/addons_manager.cpp b/src/addons/addons_manager.cpp index 4e8da5a15..b4f0d98b3 100644 --- a/src/addons/addons_manager.cpp +++ b/src/addons/addons_manager.cpp @@ -128,7 +128,7 @@ void AddonsManager::initOnline(const XMLNode *xml) } // for igetNumNodes delete xml; - m_state.set(STATE_READY); + m_state.setAtomic(STATE_READY); downloadIcons(); } // initOnline @@ -177,7 +177,7 @@ void *AddonsManager::downloadIcons() */ bool AddonsManager::onlineReady() { - return m_state.get()==STATE_READY; + return m_state.getAtomic()==STATE_READY; } // onlineReady // ---------------------------------------------------------------------------- diff --git a/src/addons/addons_manager.hpp b/src/addons/addons_manager.hpp index ed9530764..a9d4570e4 100644 --- a/src/addons/addons_manager.hpp +++ b/src/addons/addons_manager.hpp @@ -59,7 +59,7 @@ public: void initOnline(const XMLNode *xml); bool onlineReady(); /** Marks addon as not being available. */ - void setErrorState() { m_state.set(STATE_ERROR); } + void setErrorState() { m_state.setAtomic(STATE_ERROR); } const Addon* getAddon(const std::string &id) const; int getAddonIndex(const std::string &id) const; bool install(const Addon &addon); diff --git a/src/addons/network_http.cpp b/src/addons/network_http.cpp index a991c9b44..900b4eb56 100644 --- a/src/addons/network_http.cpp +++ b/src/addons/network_http.cpp @@ -98,7 +98,7 @@ void NetworkHttp::startNetworkThread() pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - m_thread_id.set(new pthread_t()); + m_thread_id.setAtomic(new pthread_t()); int error = pthread_create(m_thread_id.getData(), &attr, &NetworkHttp::mainLoop, this); if(error) @@ -106,7 +106,7 @@ void NetworkHttp::startNetworkThread() m_thread_id.lock(); delete m_thread_id.getData(); m_thread_id.unlock(); - m_thread_id.set(0); + m_thread_id.setAtomic(0); printf("[addons] Warning: could not create thread, error=%d.\n", errno); } pthread_attr_destroy(&attr); @@ -426,7 +426,7 @@ void NetworkHttp::cancelAllDownloads() { if(UserConfigParams::logAddons()) printf("[addons] Requesting cancellation of download.\n"); - m_abort.set(true); + m_abort.setAtomic(true); } // cancelAllDownload // ---------------------------------------------------------------------------- @@ -495,15 +495,15 @@ int NetworkHttp::progressDownload(void *clientp, Request *request = (Request *)clientp; // Check if we are asked to abort the download. If so, signal this // back to libcurl by returning a non-zero status. - if(network_http->m_abort.get() || request->isCancelled() ) + if(network_http->m_abort.getAtomic() || request->isCancelled() ) { if(UserConfigParams::logAddons()) { - if(network_http->m_abort.get()) + if(network_http->m_abort.getAtomic()) { // Reset abort flag so that the next download will work // as expected. - network_http->m_abort.set(false); + network_http->m_abort.setAtomic(false); printf("[addons] Global abort of downloads.\n"); } else diff --git a/src/addons/request.cpp b/src/addons/request.cpp index aac4e4ba2..bb886beb9 100644 --- a/src/addons/request.cpp +++ b/src/addons/request.cpp @@ -31,7 +31,7 @@ Request::Request(HttpCommands command, int priority, bool manage_memory) m_manage_memory = manage_memory; m_icon_addon = NULL; m_cancel = false; - m_progress.set(0); + m_progress.setAtomic(0); } // Request // ---------------------------------------------------------------------------- @@ -46,7 +46,7 @@ Request::Request(HttpCommands command, int priority, bool manage_memory, m_icon_addon = NULL; m_manage_memory = manage_memory; m_cancel = false; - m_progress.set(0); + m_progress.setAtomic(0); } // Request // ---------------------------------------------------------------------------- diff --git a/src/addons/request.hpp b/src/addons/request.hpp index 5d9975f5f..ec46c2329 100644 --- a/src/addons/request.hpp +++ b/src/addons/request.hpp @@ -89,10 +89,10 @@ public: int getPriority() const { return m_priority; } // -------------------------------------------------------------------- /** Returns the current progress. */ - float getProgress() const { return m_progress.get(); } + float getProgress() const { return m_progress.getAtomic(); } // -------------------------------------------------------------------- /** Sets the current progress. */ - void setProgress(float f) { m_progress.set(f); } + void setProgress(float f) { m_progress.setAtomic(f); } // -------------------------------------------------------------------- /** Used in sorting requests by priority. */ bool operator<(const Request &r) { return r.m_priority < m_priority;} diff --git a/src/utils/synchronised.hpp b/src/utils/synchronised.hpp index c319749d2..364bc456a 100644 --- a/src/utils/synchronised.hpp +++ b/src/utils/synchronised.hpp @@ -53,7 +53,7 @@ public: /** Sets the value of this variable using a mutex. * \param v Value to be set. */ - void set(const TYPE &v) + void setAtomic(const TYPE &v) { pthread_mutex_lock(&m_mutex); m_data = v; @@ -63,7 +63,7 @@ public: // ------------------------------------------------------------------------ /** Returns a copy of this variable. */ - TYPE get() const + TYPE getAtomic() const { TYPE v; pthread_mutex_lock(&m_mutex);