[gnote] Replace Glib::Mutex with std::mutex in TagManager



commit b13b7c4b0bdac582e877dc0c11c1148b75fd491a
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun May 2 20:35:09 2021 +0300

    Replace Glib::Mutex with std::mutex in TagManager

 src/tagmanager.cpp | 15 ++++++---------
 src/tagmanager.hpp |  5 ++---
 2 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/src/tagmanager.cpp b/src/tagmanager.cpp
index 2b9c1e3d..3b833676 100644
--- a/src/tagmanager.cpp
+++ b/src/tagmanager.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011,2013-2014,2017,2019 Aurimas Cernius
+ * Copyright (C) 2011,2013-2014,2017,2019,2021 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -74,7 +74,7 @@ namespace gnote {
     std::vector<Glib::ustring> splits;
     sharp::string_split(splits, normalized_tag_name, ":");
     if ((splits.size() > 2) || Glib::str_has_prefix(normalized_tag_name, Tag::SYSTEM_TAG_PREFIX)) {
-      Glib::Mutex::Lock lock(m_locker);
+      std::lock_guard<std::mutex> lock(m_locker);
       auto iter = m_internal_tags.find(normalized_tag_name);
       if(iter != m_internal_tags.end()) {
         return iter->second;
@@ -105,7 +105,7 @@ namespace gnote {
     std::vector<Glib::ustring> splits;
     sharp::string_split(splits, normalized_tag_name, ":");
     if ((splits.size() > 2) || Glib::str_has_prefix(normalized_tag_name, Tag::SYSTEM_TAG_PREFIX)){
-      Glib::Mutex::Lock lock(m_locker);
+      std::lock_guard<std::mutex> lock(m_locker);
       auto iter = m_internal_tags.find(normalized_tag_name);
       if(iter != m_internal_tags.end()) {
         return iter->second;
@@ -120,8 +120,7 @@ namespace gnote {
     bool tag_added = false;
     Tag::Ptr tag = get_tag (normalized_tag_name);
     if (!tag) {
-
-      Glib::Mutex::Lock lock(m_locker);
+      std::lock_guard<std::mutex> lock(m_locker);
 
       tag = get_tag (normalized_tag_name);
       if (!tag) {
@@ -182,16 +181,14 @@ namespace gnote {
       throw sharp::Exception ("TagManager.RemoveTag () called with a null tag");
 
     if(tag->is_property() || tag->is_system()){
-
-      Glib::Mutex::Lock lock(m_locker);
+      std::lock_guard<std::mutex> lock(m_locker);
 
       m_internal_tags.erase(tag->normalized_name());
     }
     bool tag_removed = false;
     auto map_iter = m_tag_map.find(tag->normalized_name());
     if (map_iter != m_tag_map.end()) {
-
-      Glib::Mutex::Lock lock(m_locker);
+      std::lock_guard<std::mutex> lock(m_locker);
 
       map_iter = m_tag_map.find(tag->normalized_name());
       if (map_iter != m_tag_map.end()) {
diff --git a/src/tagmanager.hpp b/src/tagmanager.hpp
index 9b3dac03..46ab5b62 100644
--- a/src/tagmanager.hpp
+++ b/src/tagmanager.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2013,2017,2019 Aurimas Cernius
+ * Copyright (C) 2013,2017,2019,2021 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -27,7 +27,6 @@
 
 #include <sigc++/signal.h>
 
-#include <glibmm/thread.h>
 #include <gtkmm/liststore.h>
 #include <gtkmm/treemodelsort.h>
 
@@ -72,7 +71,7 @@ private:
   TagMap                           m_tag_map;
   typedef std::map<Glib::ustring, Tag::Ptr> InternalMap;
   InternalMap                      m_internal_tags;
-  mutable Glib::Mutex              m_locker;
+  mutable std::mutex               m_locker;
   
   sigc::signal<void, Tag::Ptr, const Gtk::TreeIter &> m_signal_tag_added;
   sigc::signal<void, const Glib::ustring &> m_signal_tag_removed;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]