]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttle: added pending_error method to SimpleThrottle
authorJason Dillaman <dillaman@redhat.com>
Thu, 9 Apr 2015 01:48:21 +0000 (21:48 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 26 May 2015 18:25:19 +0000 (14:25 -0400)
Allow the client of SimpleThrottle to detect an async error
so that it can exit early.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/common/Throttle.cc
src/common/Throttle.h

index 42c633bd3aa70f97961be37ad9bbabb4fb1c5f05..307c0ec9e4b857baa0a6229f746a815d963894cb 100644 (file)
@@ -269,6 +269,12 @@ void SimpleThrottle::end_op(int r)
   m_cond.Signal();
 }
 
+bool SimpleThrottle::pending_error() const
+{
+  Mutex::Locker l(m_lock);
+  return (m_ret < 0);
+}
+
 int SimpleThrottle::wait_for_ret()
 {
   Mutex::Locker l(m_lock);
index 5c97486f1b3c431bf6442dd01ff0f3299006d0f7..4a3962beca3de7fe2ea1ed8238248a6ff533b828 100644 (file)
@@ -120,9 +120,10 @@ public:
   ~SimpleThrottle();
   void start_op();
   void end_op(int r);
+  bool pending_error() const;
   int wait_for_ret();
 private:
-  Mutex m_lock;
+  mutable Mutex m_lock;
   Cond m_cond;
   uint64_t m_max;
   uint64_t m_current;