You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/01/26 21:12:40 UTC
svn commit: r615481 -
/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
Author: tabish
Date: Sat Jan 26 12:12:38 2008
New Revision: 615481
URL: http://svn.apache.org/viewvc?rev=615481&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-152
Fixing a little compiler warning.
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp?rev=615481&r1=615480&r2=615481&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp Sat Jan 26 12:12:38 2008
@@ -22,10 +22,10 @@
using namespace std;
////////////////////////////////////////////////////////////////////////////////
-SessionPool::SessionPool( cms::Connection* connection,
+SessionPool::SessionPool( cms::Connection* connection,
cms::Session::AcknowledgeMode ackMode,
ResourceLifecycleManager* resourceLifecycleManager) {
-
+
this->connection = connection;
this->acknowledgeMode = ackMode;
this->resourceLifecycleManager = resourceLifecycleManager;
@@ -33,7 +33,7 @@
////////////////////////////////////////////////////////////////////////////////
SessionPool::~SessionPool() {
-
+
// Destroy all of the pooled session objects.
list<PooledSession*>::iterator iter = sessions.begin();
for( ; iter != sessions.end(); ++iter ) {
@@ -45,45 +45,48 @@
////////////////////////////////////////////////////////////////////////////////
PooledSession* SessionPool::takeSession() throw (cms::CMSException){
-
+
synchronized(&mutex) {
-
+
PooledSession* pooledSession = NULL;
-
+
// If there are no sessions available, create a new one and return it.
if( available.size() == 0 ) {
-
+
// No sessions were available - create a new one.
cms::Session* session = connection->createSession(acknowledgeMode);
-
+
// Give this resource to the lifecycle manager to manage. The pool
// will not be in charge of destroying this resource.
resourceLifecycleManager->addSession(session);
-
+
// Now wrap the session with a pooled session.
PooledSession* pooledSession = new PooledSession(this, session);
-
+
// Add to the sessions list.
sessions.push_back(pooledSession);
-
+
} else {
-
+
// There are sessions available - use the one at the head of the
// list, and remove it from the available list.
pooledSession = available.front();
available.pop_front();
}
-
+
// Return the session.
return pooledSession;
}
+
+ // Fixes compiler warnings.
+ return NULL;
}
////////////////////////////////////////////////////////////////////////////////
void SessionPool::returnSession( PooledSession* session ) {
-
- synchronized(&mutex) {
-
+
+ synchronized(&mutex) {
+
// Add to the available list.
available.push_back(session);
}