activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r705899 - in /activemq/activemq-cpp/branches/pools-revamp/src: main/ main/activemq/support/ main/decaf/internal/ main/decaf/lang/ test/
Date Sat, 18 Oct 2008 17:53:44 GMT
Author: tabish
Date: Sat Oct 18 10:53:43 2008
New Revision: 705899

URL: http://svn.apache.org/viewvc?rev=705899&view=rev
Log:
Attempt to resolve pool issues on CentOS and REHL

Added:
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp 
 (contents, props changed)
      - copied, changed from r705894, activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.cpp
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h   (contents,
props changed)
      - copied, changed from r705894, activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.h
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Runtime.h
Removed:
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprRuntime.cpp
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprRuntime.h
Modified:
    activemq/activemq-cpp/branches/pools-revamp/src/main/Makefile.am
    activemq/activemq-cpp/branches/pools-revamp/src/main/activemq/support/InitDirector.cpp
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.cpp
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.h
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.cpp
    activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.h
    activemq/activemq-cpp/branches/pools-revamp/src/test/main.cpp

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/Makefile.am?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/Makefile.am Sat Oct 18 10:53:43 2008
@@ -81,7 +81,7 @@
     activemq/transport/filters/TcpTransportFactory.cpp \
     activemq/transport/filters/LoggingTransport.cpp \
     activemq/transport/filters/LoggingTransportFactory.cpp \
-    decaf/internal/AprRuntime.cpp \
+    decaf/internal/DecafRuntime.cpp \
     decaf/internal/AprPool.cpp \
     decaf/internal/util/ByteArrayAdapter.cpp \
     decaf/internal/util/HexStringParser.cpp \
@@ -348,6 +348,7 @@
     decaf/lang/Thread.h \
     decaf/lang/Number.h \
     decaf/lang/Runnable.h \
+    decaf/lang/Runtime.h \
     decaf/lang/Math.h \
     decaf/lang/System.h \
     decaf/lang/Boolean.h \
@@ -425,7 +426,7 @@
     decaf/util/logging/SimpleLogger.h \
     decaf/util/logging/PropertiesChangeListener.h \
     decaf/internal/AprPool.h \
-    decaf/internal/AprRuntime.h \
+    decaf/internal/DecafRuntime.h \
     decaf/internal/util/HexStringParser.h \
     decaf/internal/util/ByteArrayAdapter.h \
     decaf/internal/nio/BufferFactory.h \

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/activemq/support/InitDirector.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/activemq/support/InitDirector.cpp?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/activemq/support/InitDirector.cpp
(original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/activemq/support/InitDirector.cpp
Sat Oct 18 10:53:43 2008
@@ -17,7 +17,7 @@
 #include "InitDirector.h"
 
 #include <decaf/util/logging/LogWriter.h>
-#include <decaf/internal/AprPool.h>
+#include <decaf/lang/Runtime.h>
 #include <activemq/transport/IOTransportFactory.h>
 #include <activemq/transport/MockTransportFactory.h>
 #include <activemq/transport/filters/AsyncSendTransportFactory.h>
@@ -37,8 +37,7 @@
 InitDirector::InitDirector() {
 
     if( refCount == 0 ) {
-        decaf::internal::AprPool initPools;
-        initPools.getAprPool();
+        decaf::lang::Runtime::getRuntime();
         connector::stomp::StompConnectorFactory::getInstance();
         connector::openwire::OpenWireConnectorFactory::getInstance();
         transport::filters::TcpTransportFactory::getInstance();

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.cpp?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.cpp (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.cpp Sat Oct
18 10:53:43 2008
@@ -16,6 +16,7 @@
  */
 
 #include "AprPool.h"
+#include <decaf/lang/Runtime.h>
 
 using namespace decaf;
 using namespace decaf::internal;
@@ -36,7 +37,7 @@
 void AprPool::allocatePool() const {
 
     if( aprPool == NULL ) {
-        apr_pool_create( &aprPool, NULL );
+        apr_pool_create_unmanaged( &aprPool );
     }
 }
 
@@ -61,10 +62,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 apr_pool_t* AprPool::getAprPool() const {
 
-    // Creates a single static instance that will on the first call
-    // init apr and remain in memory until we shutdown and then free
-    // the apr resources.
-    static AprRuntime aprRuntime;
+    // Ensure there is a Runtime instance created.
+    decaf::lang::Runtime::getRuntime();
 
     // Ensure that the pool has been allocated.
     allocatePool();

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.h?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.h (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/AprPool.h Sat Oct
18 10:53:43 2008
@@ -19,7 +19,6 @@
 #define _DECAF_INTERNAL_APRPOOL_H_
 
 #include <decaf/util/Config.h>
-#include <decaf/internal/AprRuntime.h>
 
 #include <apr_pools.h>
 

Copied: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp
(from r705894, activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.cpp)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp?p2=activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp&p1=activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.cpp&r1=705894&r2=705899&rev=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.cpp (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp Sat
Oct 18 10:53:43 2008
@@ -15,25 +15,46 @@
  * limitations under the License.
  */
 
-#include "AprRuntime.h"
+#include "DecafRuntime.h"
 
 #include <apr.h>
 #include <apr_general.h>
 #include <apr_pools.h>
 
+using namespace decaf;
 using namespace decaf::internal;
+using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-AprRuntime::AprRuntime() {
-            
+DecafRuntime::DecafRuntime() {
+
     // Initializes the APR Runtime from within a library.
     apr_initialize();
+
+    // Create a Global Pool for Threads to use
+    apr_pool_create_ex( &aprPool, NULL, NULL, NULL );
+
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-AprRuntime::~AprRuntime() {
-    
+DecafRuntime::~DecafRuntime() {
+
+    // Destroy the Global Thread Memory Pool
+    apr_pool_destroy( aprPool );
+
     // Cleans up APR data structures.
     apr_terminate();
-} 
+}
 
+////////////////////////////////////////////////////////////////////////////////
+apr_pool_t* DecafRuntime::getGlobalPool() const {
+    return this->aprPool;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Runtime* Runtime::getRuntime() {
+
+    static DecafRuntime runtime;
+
+    return &runtime;
+}

Propchange: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.cpp
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h
(from r705894, activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.h)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h?p2=activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h&p1=activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.h&r1=705894&r2=705899&rev=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/AprRuntime.h (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h Sat
Oct 18 10:53:43 2008
@@ -15,8 +15,12 @@
  * limitations under the License.
  */
 
-#ifndef _DECAF_INTERNAL_APRRUNTIME_H
-#define _DECAF_INTERNAL_APRRUNTIME_H
+#ifndef _DECAF_INTERNAL_DECAFRUNTIME_H
+#define _DECAF_INTERNAL_DECAFRUNTIME_H
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Runtime.h>
+#include <apr_pools.h>
 
 namespace decaf {
 namespace internal {
@@ -24,21 +28,34 @@
     /**
      * Handles APR initialization and termination.
      */
-    class AprRuntime {
+    class DECAF_API DecafRuntime : public decaf::lang::Runtime {
+    private:
+
+        /**
+         * Internal APR pool
+         */
+        mutable apr_pool_t* aprPool;
+
     public:
-    
+
         /**
          * Initializes the APR Runtime for a library.
          */
-        AprRuntime();
-    
+        DecafRuntime();
+
         /**
          * Terminates the APR Runtime for a library.
          */
-        virtual ~AprRuntime();
-    
+        virtual ~DecafRuntime();
+
+        /**
+         * Grants access to the Global APR Pool instance that should be
+         * used when creating new threads.
+         */
+        apr_pool_t* getGlobalPool() const;
+
     };
-    
+
 }}
 
-#endif /*_DECAF_INTERNAL_APRRUNTIME_H*/
+#endif /*_DECAF_INTERNAL_DECAFRUNTIME_H*/

Propchange: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/internal/DecafRuntime.h
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Runtime.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Runtime.h?rev=705899&view=auto
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Runtime.h (added)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Runtime.h Sat Oct 18 10:53:43
2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_LANG_RUNTIME_H_
+#define _DECAF_LANG_RUNTIME_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf {
+namespace lang {
+
+    class DECAF_API Runtime {
+    public:
+
+        virtual ~Runtime() {}
+
+        /**
+         * Gets the single instance of the Decaf Runtime for this Process.
+         *
+         * @returns pointer to the single Decaf Runtime instance that exists
+         *          for this process
+         */
+        static Runtime* getRuntime();
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_RUNTIME_H_*/

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.cpp?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.cpp (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.cpp Sat Oct 18
10:53:43 2008
@@ -20,6 +20,7 @@
 #include <apr_time.h>
 #include <apr_portable.h>
 
+#include <decaf/internal/DecafRuntime.h>
 #include <decaf/lang/Exception.h>
 #include <decaf/lang/exceptions/RuntimeException.h>
 
@@ -57,12 +58,14 @@
             "Thread::start - Thread already started");
     }
 
+    DecafRuntime* runtime = dynamic_cast<DecafRuntime*>( Runtime::getRuntime() );
+
     apr_status_t err = apr_thread_create(
         &this->threadHandle,
         NULL,
         runCallback,
         this,
-        pool.getAprPool() );
+        runtime->getGlobalPool() );
 
     if( err != APR_SUCCESS ) {
         throw Exception(

Modified: activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.h?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.h (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/main/decaf/lang/Thread.h Sat Oct 18 10:53:43
2008
@@ -23,7 +23,6 @@
 #include <stdexcept>
 #include <assert.h>
 
-#include <decaf/internal/AprPool.h>
 #include <apr_thread_proc.h>
 
 namespace decaf{
@@ -45,11 +44,6 @@
         Runnable* task;
 
         /**
-         * APR Pool to allocate thread from
-         */
-        decaf::internal::AprPool pool;
-
-        /**
          * APR Thread Handle
          */
         apr_thread_t* threadHandle;

Modified: activemq/activemq-cpp/branches/pools-revamp/src/test/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/pools-revamp/src/test/main.cpp?rev=705899&r1=705898&r2=705899&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/pools-revamp/src/test/main.cpp (original)
+++ activemq/activemq-cpp/branches/pools-revamp/src/test/main.cpp Sat Oct 18 10:53:43 2008
@@ -20,9 +20,13 @@
 #include <cppunit/BriefTestProgressListener.h>
 #include <cppunit/TestResult.h>
 #include <activemq/util/Config.h>
+#include <decaf/lang/Runtime.h>
 
 int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED)
 {
+    // ensure that we start the runtime.
+    decaf::lang::Runtime::getRuntime();
+
     CppUnit::TextUi::TestRunner runner;
     CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
     runner.addTest( registry.makeTest() );
@@ -30,7 +34,7 @@
     // Shows a message as each test starts
     CppUnit::BriefTestProgressListener listener;
     runner.eventManager().addListener( &listener );
-    
+
     bool wasSuccessful = runner.run( "", false );
     return !wasSuccessful;
 }



Mime
View raw message