activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r991380 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal: DecafRuntime.cpp DecafRuntime.h
Date Tue, 31 Aug 2010 22:37:40 GMT
Author: tabish
Date: Tue Aug 31 22:37:39 2010
New Revision: 991380

URL: http://svn.apache.org/viewvc?rev=991380&view=rev
Log:
Add a global mutex to the internal Decaf Runtime instance for use in resource acquisition.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp?rev=991380&r1=991379&r2=991380&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp Tue
Aug 31 22:37:39 2010
@@ -29,6 +29,7 @@ using namespace decaf;
 using namespace decaf::internal;
 using namespace decaf::internal::net;
 using namespace decaf::lang;
+using namespace decaf::util::concurrent;
 
 ////////////////////////////////////////////////////////////////////////////////
 namespace decaf{
@@ -38,10 +39,11 @@ namespace internal{
     public:
 
         mutable apr_pool_t* aprPool;
+        Mutex* lock;
 
     public:
 
-        RuntimeData() : aprPool(NULL) {
+        RuntimeData() : aprPool(NULL), lock(NULL) {
         }
 
     };
@@ -59,6 +61,8 @@ DecafRuntime::DecafRuntime() {
     // Create a Global Pool for Threads to use
     apr_pool_create_ex( &runtimeData->aprPool, NULL, NULL, NULL );
 
+    // Create the global Lock object now that the memory pool exists.
+    this->runtimeData->lock = new Mutex;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -66,6 +70,9 @@ DecafRuntime::~DecafRuntime() {
 
     try{
 
+        // Destory the Global Lock before we deallocate the memory pool.
+        delete this->runtimeData->lock;
+
         // Destroy the Global Thread Memory Pool
         apr_pool_destroy( this->runtimeData->aprPool );
 
@@ -85,6 +92,11 @@ apr_pool_t* DecafRuntime::getGlobalPool(
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+Mutex* DecafRuntime::getGlobalLock() {
+    return this->runtimeData->lock;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 Runtime* Runtime::getRuntime() {
 
     static DecafRuntime runtime;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.h?rev=991380&r1=991379&r2=991380&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.h Tue Aug
31 22:37:39 2010
@@ -20,6 +20,7 @@
 
 #include <decaf/util/Config.h>
 #include <decaf/lang/Runtime.h>
+#include <decaf/util/concurrent/Mutex.h>
 
 #include <apr_pools.h>
 
@@ -54,6 +55,18 @@ namespace internal {
          */
         apr_pool_t* getGlobalPool() const;
 
+        /**
+         * Gets a pointer to the Decaf Runtime's Global Lock object, this can be used by
+         * Decaf APIs to synchronize around certain actions such as adding or acquiring
+         * a resource that must be Thread safe.
+         *
+         * The pointer returned is owned by the Decaf runtime and should not be
+         * deleted or copied by the caller.
+         *
+         * @returns a pointer to the Decaf Runtime's global Lock instance.
+         */
+        decaf::util::concurrent::Mutex* getGlobalLock();
+
     };
 
 }}



Mime
View raw message