Browse Source

[2198] Add AlreadyLocked exception to Mutex::Locker

Mukund Sivaraman 12 years ago
parent
commit
1b638d6813
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/lib/util/threads/sync.h

+ 10 - 0
src/lib/util/threads/sync.h

@@ -15,6 +15,8 @@
 #ifndef B10_THREAD_SYNC_H
 #define B10_THREAD_SYNC_H
 
+#include <exceptions/exceptions.h>
+
 #include <boost/noncopyable.hpp>
 
 #include <cstdlib> // for NULL.
@@ -77,6 +79,14 @@ public:
     /// of function no matter by what means.
     class Locker : boost::noncopyable {
     public:
+        /// \brief Exception thrown when the mutex is already locked and
+        ///     a non-blocking locker is attempted around it.
+        struct AlreadyLocked : public isc::InvalidParameter {
+            AlreadyLocked(const char* file, size_t line, const char* what) :
+                isc::InvalidParameter(file, line, what)
+            {}
+        };
+
         /// \brief Constructor.
         ///
         /// Locks the mutex. May block for extended period of time.