]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: std::lock_guard<...> -> std::lock_guard
authorSage Weil <sage@redhat.com>
Tue, 16 Oct 2018 19:40:13 +0000 (14:40 -0500)
committerKefu Chai <kchai@redhat.com>
Wed, 21 Nov 2018 03:56:33 +0000 (11:56 +0800)
Signed-off-by: Sage Weil <sage@redhat.com>
13 files changed:
src/common/Cond.h
src/common/ContextCompletion.cc
src/common/Readahead.cc
src/common/Throttle.cc
src/common/Throttle.h
src/common/WorkQueue.h
src/common/buffer.cc
src/common/ceph_context.cc
src/common/ceph_context.h
src/common/ceph_timer.h
src/common/config_proxy.h
src/common/item_history.h
src/common/mempool.cc

index 383ff6ebef38b9266899250d6029304d619728ea..77b3882abb61b4d50bec3a29104127d656a9965a 100644 (file)
@@ -183,7 +183,7 @@ public:
 
   /// We overload complete in order to not delete the context
   void complete(int r) override {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     done = true;
     rval = r;
     cond.Signal();
@@ -191,7 +191,7 @@ public:
 
   /// Returns rval once the Context is called
   int wait() {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     while (!done)
       cond.Wait(lock);
     return rval;
@@ -201,7 +201,7 @@ public:
   int wait_for(double secs) {
     utime_t interval;
     interval.set_from_double(secs);
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     if (done) {
       return rval;
     }
index 8059121992600d4d792351d5f0ea7c123fd29ad2..350ad4f092cc5ed87df24b15e9e83dc74c0cb053 100644 (file)
@@ -14,7 +14,7 @@ ContextCompletion::ContextCompletion(Context *ctx, bool ignore_enoent)
 void ContextCompletion::finish_adding_requests() {
   bool complete;
   {
-    std::lock_guard<Mutex> l(m_lock);
+    std::lock_guard l(m_lock);
     m_building = false;
     complete = (m_current_ops == 0);
   }
@@ -25,14 +25,14 @@ void ContextCompletion::finish_adding_requests() {
 }
 
 void ContextCompletion::start_op() {
-  std::lock_guard<Mutex> l(m_lock);
+  std::lock_guard l(m_lock);
   ++m_current_ops;
 }
 
 void ContextCompletion::finish_op(int r) {
   bool complete;
   {
-    std::lock_guard<Mutex> l(m_lock);
+    std::lock_guard l(m_lock);
     if (r < 0 && m_ret == 0 && (!m_ignore_enoent || r != -ENOENT)) {
       m_ret = r;
     }
index 2db3950c54408414a1bd2d21e2ef649539605908..51964fcd50e0a412cbca4eb8249141ba12386fdf 100644 (file)
@@ -168,12 +168,12 @@ void Readahead::set_trigger_requests(int trigger_requests) {
 }
 
 uint64_t Readahead::get_min_readahead_size(void) {
-  std::lock_guard<Mutex> lock(m_lock);
+  std::lock_guard lock(m_lock);
   return m_readahead_min_bytes;
 }
 
 uint64_t Readahead::get_max_readahead_size(void) {
-  std::lock_guard<Mutex> lock(m_lock);
+  std::lock_guard lock(m_lock);
   return m_readahead_max_bytes;
 }
 
index f3a3bd02f9b843380d686b3107ee038be5149ae5..0bb27d71357f61eec880afe77edc5b3b48181eca 100644 (file)
@@ -706,13 +706,13 @@ TokenBucketThrottle::TokenBucketThrottle(
 TokenBucketThrottle::~TokenBucketThrottle() {
   // cancel the timer events.
   {
-    std::lock_guard<Mutex> timer_locker(*m_timer_lock);
+    std::lock_guard timer_locker(*m_timer_lock);
     cancel_timer();
   }
 
   list<Blocker> tmp_blockers;
   {
-    std::lock_guard<Mutex> blockers_lock(m_lock);
+    std::lock_guard blockers_lock(m_lock);
     tmp_blockers.splice(tmp_blockers.begin(), m_blockers, m_blockers.begin(), m_blockers.end());
   }
 
@@ -765,7 +765,7 @@ int TokenBucketThrottle::set_limit(uint64_t average, uint64_t burst) {
 }
 
 void TokenBucketThrottle::set_schedule_tick_min(uint64_t tick) {
-  std::lock_guard<Mutex> lock(m_lock);
+  std::lock_guard lock(m_lock);
   if (tick != 0) {
     m_tick_min = tick;
   }
@@ -790,7 +790,7 @@ uint64_t TokenBucketThrottle::tokens_this_tick() {
 void TokenBucketThrottle::add_tokens() {
   list<Blocker> tmp_blockers;
   {
-    std::lock_guard<Mutex> lock(m_lock);
+    std::lock_guard lock(m_lock);
     // put tokens into bucket.
     m_throttle.put(tokens_this_tick());
     // check the m_blockers from head to tail, if blocker can get
index 4febe1d7a036d9fc62c82c99f162b5962d51ddef..46ff1c51702f8528e25bc1cf4ed7cfce84a55e55 100644 (file)
@@ -427,7 +427,7 @@ public:
   
     bool wait = false;
     uint64_t got = 0;
-    std::lock_guard<Mutex> lock(m_lock);
+    std::lock_guard lock(m_lock);
     if (!m_blockers.empty()) {
       // Keep the order of requests, add item after previous blocked requests.
       wait = true;
index 66696d01a8f05c6240f8da522890b872e24bc740..82acfeeba1b26fc52b7448fe5018f243e0df0258 100644 (file)
@@ -191,7 +191,7 @@ public:
 
     void *_void_dequeue() override {
       {
-       std::lock_guard<Mutex> l(_lock);
+       std::lock_guard l(_lock);
        if (_empty())
          return 0;
        U u = _dequeue();
@@ -234,12 +234,12 @@ public:
       pool->remove_work_queue(this);
     }
     void queue(T item) {
-      std::lock_guard<Mutex> l(pool->_lock);
+      std::lock_guard l(pool->_lock);
       _enqueue(item);
       pool->_cond.SignalOne();
     }
     void queue_front(T item) {
-      std::lock_guard<Mutex> l(pool->_lock);
+      std::lock_guard l(pool->_lock);
       _enqueue_front(item);
       pool->_cond.SignalOne();
     }
@@ -353,7 +353,7 @@ public:
       {
         // if this queue is empty and not processing, don't wait for other
         // queues to finish processing
-        std::lock_guard<Mutex> l(m_pool->_lock);
+        std::lock_guard l(m_pool->_lock);
         if (m_processing == 0 && m_items.empty()) {
           return;
         }
@@ -361,12 +361,12 @@ public:
       m_pool->drain(this);
     }
     void queue(T *item) {
-      std::lock_guard<Mutex> l(m_pool->_lock);
+      std::lock_guard l(m_pool->_lock);
       m_items.push_back(item);
       m_pool->_cond.SignalOne();
     }
     bool empty() {
-      std::lock_guard<Mutex> l(m_pool->_lock);
+      std::lock_guard l(m_pool->_lock);
       return _empty();
     }
   protected:
@@ -406,7 +406,7 @@ public:
 
     virtual void process(T *item) = 0;
     void process_finish() {
-      std::lock_guard<Mutex> locker(m_pool->_lock);
+      std::lock_guard locker(m_pool->_lock);
       _void_process_finish(nullptr);
     }
 
@@ -418,12 +418,12 @@ public:
       return m_items.front();
     }
     void requeue(T *item) {
-      std::lock_guard<Mutex> pool_locker(m_pool->_lock);
+      std::lock_guard pool_locker(m_pool->_lock);
       _void_process_finish(nullptr);
       m_items.push_front(item);
     }
     void signal() {
-      std::lock_guard<Mutex> pool_locker(m_pool->_lock);
+      std::lock_guard pool_locker(m_pool->_lock);
       m_pool->_cond.SignalOne();
     }
     Mutex &get_pool_lock() {
@@ -464,18 +464,18 @@ public:
 
   /// return number of threads currently running
   int get_num_threads() {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     return _num_threads;
   }
   
   /// assign a work queue to this thread pool
   void add_work_queue(WorkQueue_* wq) {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     work_queues.push_back(wq);
   }
   /// remove a work queue from this thread pool
   void remove_work_queue(WorkQueue_* wq) {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     unsigned i = 0;
     while (work_queues[i] != wq)
       i++;
@@ -505,7 +505,7 @@ public:
   }
   /// wake up a waiter (without lock held)
   void wake() {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     _cond.Signal();
   }
   void _wait() {
@@ -581,7 +581,7 @@ public:
 
   void queue(Context *ctx, int result = 0) {
     if (result != 0) {
-      std::lock_guard<Mutex> locker(m_lock);
+      std::lock_guard locker(m_lock);
       m_context_results[ctx] = result;
     }
     ThreadPool::PointerWQ<Context>::queue(ctx);
@@ -590,14 +590,14 @@ protected:
   void _clear() override {
     ThreadPool::PointerWQ<Context>::_clear();
 
-    std::lock_guard<Mutex> locker(m_lock);
+    std::lock_guard locker(m_lock);
     m_context_results.clear();
   }
 
   void process(Context *ctx) override {
     int result = 0;
     {
-      std::lock_guard<Mutex> locker(m_lock);
+      std::lock_guard locker(m_lock);
       ceph::unordered_map<Context *, int>::iterator it =
         m_context_results.find(ctx);
       if (it != m_context_results.end()) {
index b96bd80f4b696389e32e4224d9917dcf007064a4..332d8e54fda3f323fdd36f2141fb753888bc5908 100644 (file)
@@ -45,7 +45,7 @@ using namespace ceph;
 #define CEPH_BUFFER_APPEND_SIZE (CEPH_BUFFER_ALLOC_UNIT - sizeof(raw_combined))
 
 #ifdef BUFFER_DEBUG
-# define bdout { std::lock_guard<ceph::spinlock> lg(ceph::spinlock()); std::cout
+# define bdout { std::lock_guard lg(ceph::spinlock()); std::cout
 # define bendl std::endl; }
 #else
 # define bdout if (0) { std::cout
index d5f4c02a4ff73eae3541b4394f77c9dc439c27f3..e432a8ecbe8d864d4e0d2506a2f605b82bef90d2 100644 (file)
@@ -351,7 +351,7 @@ public:
                           const std::set <std::string> &changed) override {
     if (changed.count(
          "enable_experimental_unrecoverable_data_corrupting_features")) {
-      std::lock_guard<ceph::spinlock> lg(cct->_feature_lock);
+      std::lock_guard lg(cct->_feature_lock);
       get_str_set(
        conf->enable_experimental_unrecoverable_data_corrupting_features,
        cct->_experimental_features);
@@ -743,7 +743,7 @@ void CephContext::shutdown_crypto()
 void CephContext::start_service_thread()
 {
   {
-    std::lock_guard<ceph::spinlock> lg(_service_thread_lock);
+    std::lock_guard lg(_service_thread_lock);
     if (_service_thread) {
       return;
     }
@@ -770,7 +770,7 @@ void CephContext::start_service_thread()
 
 void CephContext::reopen_logs()
 {
-  std::lock_guard<ceph::spinlock> lg(_service_thread_lock);
+  std::lock_guard lg(_service_thread_lock);
   if (_service_thread)
     _service_thread->reopen_logs();
 }
@@ -901,7 +901,7 @@ CryptoHandler *CephContext::get_crypto_handler(int type)
 void CephContext::notify_pre_fork()
 {
   {
-    std::lock_guard<ceph::spinlock> lg(_fork_watchers_lock);
+    std::lock_guard lg(_fork_watchers_lock);
     for (auto &&t : _fork_watchers) {
       t->handle_pre_fork();
     }
index 990c34e8cf39aabba8446e1d7821e971b00594ea..7e064e21327730bcc9ead7d2717beefadcb1eecc 100644 (file)
@@ -225,7 +225,7 @@ public:
   };
 
   void register_fork_watcher(ForkWatcher *w) {
-    std::lock_guard<ceph::spinlock> lg(_fork_watchers_lock);
+    std::lock_guard lg(_fork_watchers_lock);
     _fork_watchers.push_back(w);
   }
 
index bca800b88e4ea57b43dba5ba052a9dff29b6ae50..623e21d975d34186d73ab4eca2a99aab54810b4e 100644 (file)
@@ -207,7 +207,7 @@ namespace ceph {
       template<typename Callable, typename... Args>
       uint64_t add_event(typename TC::time_point when,
                         Callable&& f, Args&&... args) {
-       std::lock_guard<std::mutex> l(lock);
+       std::lock_guard l(lock);
        event& e = *(new event(
                       when, ++next_id,
                       std::forward<std::function<void()> >(
@@ -237,7 +237,7 @@ namespace ceph {
 
       // Adjust the timeout of a currently-scheduled event (absolute)
       bool adjust_event(uint64_t id, typename TC::time_point when) {
-       std::lock_guard<std::mutex> l(lock);
+       std::lock_guard l(lock);
 
        event key(id);
        typename event_set_type::iterator it = events.find(key);
@@ -258,7 +258,7 @@ namespace ceph {
       // never submitted it) you will receive false. Otherwise you will
       // receive true and it is guaranteed the event will not execute.
       bool cancel_event(const uint64_t id) {
-       std::lock_guard<std::mutex> l(lock);
+       std::lock_guard l(lock);
        event dummy(id);
        auto p = events.find(dummy);
        if (p == events.end()) {
@@ -298,7 +298,7 @@ namespace ceph {
       uint64_t reschedule_me(typename TC::time_point when) {
        if (std::this_thread::get_id() != thread.get_id())
          throw std::make_error_condition(std::errc::operation_not_permitted);
-       std::lock_guard<std::mutex> l(lock);
+       std::lock_guard l(lock);
        running->t = when;
        uint64_t id = ++next_id;
        running->id = id;
@@ -314,7 +314,7 @@ namespace ceph {
 
       // Remove all events from the queue.
       void cancel_all_events() {
-       std::lock_guard<std::mutex> l(lock);
+       std::lock_guard l(lock);
        while (!events.empty()) {
          auto p = events.begin();
          event& e = *p;
index 1ae56ebde30a0ca07be45e9d76dd2508ed688dd1..f3dc8d664c6fc54e378eac142d3adef3ee1e92b4 100644 (file)
@@ -47,21 +47,21 @@ public:
     return &values;
   }
   int get_val(const std::string& key, char** buf, int len) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.get_val(values, key, buf, len);
   }
   int get_val(const std::string &key, std::string *val) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.get_val(values, key, val);
   }
   template<typename T>
   const T get_val(const std::string& key) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.template get_val<T>(values, key);
   }
   template<typename T, typename Callback, typename...Args>
   auto with_val(const string& key, Callback&& cb, Args&&... args) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.template with_val<T>(values, key,
                                       std::forward<Callback>(cb),
                                       std::forward<Args>(args)...);
@@ -84,21 +84,21 @@ public:
     return config.find_option(name);
   }
   void diff(Formatter *f, const std::string& name=string{}) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.diff(values, f, name);
   }
   void get_my_sections(std::vector <std::string> &sections) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.get_my_sections(values, sections);
   }
   int get_all_sections(std::vector<std::string>& sections) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.get_all_sections(sections);
   }
   int get_val_from_conf_file(const std::vector<std::string>& sections,
                             const std::string& key, std::string& out,
                             bool emeta) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.get_val_from_conf_file(values,
                                         sections, key, out, emeta);
   }
@@ -107,27 +107,27 @@ public:
   }
   void early_expand_meta(std::string &val,
                         std::ostream *oss) const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.early_expand_meta(values, val, oss);
   }
   // for those want to reexpand special meta, e.g, $pid
   void finalize_reexpand_meta() {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     if (config.finalize_reexpand_meta(values, obs_mgr)) {
       obs_mgr.apply_changes(values.changed, *this, nullptr);
       values.changed.clear();
     }
   }
   void add_observer(md_config_obs_t* obs) {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     obs_mgr.add_observer(obs);
   }
   void remove_observer(md_config_obs_t* obs) {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     obs_mgr.remove_observer(obs);
   }
   void call_all_observers() {
-    std::lock_guard<Mutex> l(lock);
+    std::lock_guard l(lock);
     // Have the scope of the lock extend to the scope of
     // handle_conf_change since that function expects to be called with
     // the lock held. (And the comment in config.h says that is the
@@ -145,24 +145,24 @@ public:
     config._clear_safe_to_start_threads();
   }
   void show_config(std::ostream& out) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.show_config(values, out);
   }
   void show_config(Formatter *f) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.show_config(values, f);
   }
   void config_options(Formatter *f) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.config_options(f);
   }
   int rm_val(const std::string& key) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.rm_val(values, key);
   }
   // Expand all metavariables. Make any pending observer callbacks.
   void apply_changes(std::ostream* oss) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     // apply changes until the cluster name is assigned
     if (!values.cluster.empty()) {
       // meta expands could have modified anything.  Copy it all out again.
@@ -172,44 +172,44 @@ public:
   }
   int set_val(const std::string& key, const std::string& s,
               std::stringstream* err_ss=nullptr) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.set_val(values, obs_mgr, key, s);
   }
   void set_val_default(const std::string& key, const std::string& val) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.set_val_default(values, obs_mgr, key, val);
   }
   void set_val_or_die(const std::string& key, const std::string& val) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.set_val_or_die(values, obs_mgr, key, val);
   }
   int set_mon_vals(CephContext *cct,
                   const map<std::string,std::string>& kv,
                   md_config_t::config_callback config_cb) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     int ret = config.set_mon_vals(cct, values, obs_mgr, kv, config_cb);
     obs_mgr.apply_changes(values.changed, *this, nullptr);
     values.changed.clear();
     return ret;
   }
   int injectargs(const std::string &s, std::ostream *oss) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     int ret = config.injectargs(values, obs_mgr, s, oss);
     obs_mgr.apply_changes(values.changed, *this, oss);
     values.changed.clear();
     return ret;
   }
   void parse_env(const char *env_var = "CEPH_ARGS") {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.parse_env(values, obs_mgr, env_var);
   }
   int parse_argv(std::vector<const char*>& args, int level=CONF_CMDLINE) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.parse_argv(values, obs_mgr, args, level);
   }
   int parse_config_files(const char *conf_files,
                         std::ostream *warnings, int flags) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     return config.parse_config_files(values, obs_mgr,
                                     conf_files, warnings, flags);
   }
@@ -220,17 +220,17 @@ public:
     return config.complain_about_parse_errors(cct);
   }
   void do_argv_commands() const {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.do_argv_commands(values);
   }
   void get_config_bl(uint64_t have_version,
                     bufferlist *bl,
                     uint64_t *got_version) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.get_config_bl(values, have_version, bl, got_version);
   }
   void get_defaults_bl(bufferlist *bl) {
-    std::lock_guard<Mutex> l{lock};
+    std::lock_guard l{lock};
     config.get_defaults_bl(values, bl);
   }
 };
index 987a7dcfa4de4dfddb34887fb23b07012ecacdb0..351d5ba79f027688a7610c47821ef959044cecd7 100644 (file)
@@ -49,7 +49,7 @@ public:
 
   // writes are serialized
   const T& operator=(const T& other) {
-    std::lock_guard<std::mutex> l(lock);
+    std::lock_guard l(lock);
     history.push_back(other);
     current = &history.back();
     return *current;
@@ -57,7 +57,7 @@ public:
 
   void prune() {
     // note: this is not necessarily thread-safe wrt readers
-    std::lock_guard<std::mutex> l(lock);
+    std::lock_guard l(lock);
     while (history.size() > 1) {
       history.pop_front();
     }
@@ -87,7 +87,7 @@ public:
 
   // writes are serialized
   const T& operator=(const T& other) {
-    std::lock_guard<std::mutex> l(lock);
+    std::lock_guard l(lock);
     history.push_back(other);
     current = &history.back();
     return *current;
@@ -95,7 +95,7 @@ public:
 
   void prune() {
     // note: this is not necessarily thread-safe wrt readers
-    std::lock_guard<std::mutex> l(lock);
+    std::lock_guard l(lock);
     while (history.size() > 1) {
       history.pop_front();
     }
index fd9a42d8f52ba8d0a9f0049b6d082fe363f64f87..e4ab5d4a10ad17aec05754ae236e07b77211a5ff 100644 (file)
@@ -106,7 +106,7 @@ void mempool::pool_t::get_stats(
     total->bytes += shard[i].bytes;
   }
   if (debug_mode) {
-    std::lock_guard<std::mutex> shard_lock(lock);
+    std::lock_guard shard_lock(lock);
     for (auto &p : type_map) {
       std::string n = ceph_demangle(p.second.type_name);
       stats_t &s = (*by_type)[n];