[rhmessaging-commits] rhmessaging commits: r1268 - store/trunk/cpp/lib/jrnl.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Nov 8 09:55:16 EST 2007


Author: kpvdr
Date: 2007-11-08 09:55:16 -0500 (Thu, 08 Nov 2007)
New Revision: 1268

Modified:
   store/trunk/cpp/lib/jrnl/enq_map.cpp
   store/trunk/cpp/lib/jrnl/enq_map.hpp
   store/trunk/cpp/lib/jrnl/jcntl.hpp
Log:
Added a is_enqueued(rid) fn to jcntl.

Modified: store/trunk/cpp/lib/jrnl/enq_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.cpp	2007-11-08 14:06:24 UTC (rev 1267)
+++ store/trunk/cpp/lib/jrnl/enq_map.cpp	2007-11-08 14:55:16 UTC (rev 1268)
@@ -119,6 +119,19 @@
     return fid;
 }
 
+const bool
+enq_map::is_enqueued(const u_int64_t rid)
+{
+    pthread_mutex_lock(&_mutex);
+    emap_itr itr = _map.find(rid);
+    pthread_mutex_unlock(&_mutex);
+    if (itr == _map.end()) // not found in map
+        return false;
+    if (itr->second.second) // locked
+        return false;
+    return true;
+}
+
 void
 enq_map::lock(const u_int64_t rid) throw (jexception)
 {

Modified: store/trunk/cpp/lib/jrnl/enq_map.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.hpp	2007-11-08 14:06:24 UTC (rev 1267)
+++ store/trunk/cpp/lib/jrnl/enq_map.hpp	2007-11-08 14:55:16 UTC (rev 1268)
@@ -77,6 +77,7 @@
         const u_int16_t get_fid(const u_int64_t rid) throw (jexception);
         const u_int16_t get_remove_fid(const u_int64_t rid, const bool txn_flag = false)
                 throw (jexception);
+        const bool is_enqueued(const u_int64_t rid);
         void lock(const u_int64_t rid) throw (jexception);
         void unlock(const u_int64_t rid) throw (jexception);
         const bool is_locked(const u_int64_t rid) throw (jexception);

Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp	2007-11-08 14:06:24 UTC (rev 1267)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp	2007-11-08 14:55:16 UTC (rev 1268)
@@ -555,6 +555,13 @@
                 { return _rrfc.file_handle(pi)->rd_aio_outstanding_dblks(); }
 
         /**
+        * \brief Check if a particular rid is enqueued. Note that this function will return
+        *     false if the rid is transactionally enqueued and is not committed, or if it is
+        *     locked (i.e. transactionally dequeued, but the dequeue has not been committed).
+        */
+        inline const bool is_enqueued(const u_int64_t rid) { return _emap.is_enqueued(rid); }
+        
+        /**
         * \brief Check if the journal is stopped.
         *
         * \return <b><i>true</i></b> if the jouranl is stopped;




More information about the rhmessaging-commits mailing list