Fully qualify the header filenames for doxygen.
[shibboleth/cpp-xmltooling.git] / xmltooling / util / Threads.h
index 2d6c5c3..f6fe5ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2006 Internet2
+ *  Copyright 2001-2007 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file Threads.h
+ * @file xmltooling/util/Threads.h
  * 
  * Thread and locking wrappers 
  */
@@ -78,7 +78,13 @@ namespace xmltooling
          * @param return_val    the return value for the thread
          */
         static void exit(void* return_val);
-        
+
+        /**
+         * Sleeps the current thread for the specified amount of time.
+         * 
+         * @param seconds   time to sleep
+         */
+        static void sleep(int seconds);        
 #ifndef WIN32
         /**
          * Masks all signals from a thread. 
@@ -281,22 +287,24 @@ namespace xmltooling
     /**
      * RAII wrapper for a shared lock.
      */
-    class XMLTOOL_API ReadLock {
-        MAKE_NONCOPYABLE(ReadLock);
+    class XMLTOOL_API SharedLock {
+        MAKE_NONCOPYABLE(SharedLock);
     public:
         /**
          * Locks and wraps the designated shared lock.
          * 
-         * @param lock lock to acquire 
+         * @param lock      lock to acquire 
+         * @param lockit    true if the lock should be acquired here, false if already acquired
          */
-        ReadLock(RWLock* lock) : rwlock(lock) {
-            rwlock->rdlock();
+        SharedLock(RWLock* lock, bool lockit=true) : rwlock(lock) {
+            if (lockit)
+                rwlock->rdlock();
         }
         
         /**
          * Unlocks the wrapped shared lock.
          */
-        ~ReadLock() {
+        ~SharedLock() {
             rwlock->unlock();
         }