Author: mysqlpp
Date: Sun Apr 26 04:59:41 2009
New Revision: 2505

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2505&view=rev
Log:
Extracted ConnectionPool::remove(), being just a private utility
function to do something in one place that was done the same way in
two different places before.

Modified:
    trunk/lib/cpool.cpp
    trunk/lib/cpool.h

Modified: trunk/lib/cpool.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/cpool.cpp?rev=2505&r1=2504&r2=2505&view=diff
==============================================================================
--- trunk/lib/cpool.cpp (original)
+++ trunk/lib/cpool.cpp Sun Apr 26 04:59:41 2009
@@ -1,7 +1,7 @@
 /***********************************************************************
  cpool.cpp - Implements the ConnectionPool class.
 
- Copyright (c) 2007 by Educational Technology Resources, Inc. and
+ Copyright (c) 2007-2009 by Educational Technology Resources, Inc. and
  (c) 2007 by Jonathan Wakely.  Others may also hold copyrights on
  code in this file.  See the CREDITS.txt file in the top directory
  of the distribution for details.
@@ -73,12 +73,10 @@
 {
        ScopedLock lock(mutex_);        // ensure we're not interfered with
 
-       PoolIt it = pool_.begin(), doomed;
+       PoolIt it = pool_.begin();
        while (it != pool_.end()) {
                if (all || !it->in_use) {
-                       doomed = it++;
-                       destroy(doomed->conn);
-                       pool_.erase(doomed);
+                       remove(it++);
                }
                else {
                        ++it;
@@ -141,6 +139,19 @@
 }
 
 
+//// remove ////////////////////////////////////////////////////////////
+// Given an iterator into the pool, destroy the connection and remove
+// it from the pool.  This is only a utility function for use by other
+// class internals.
+
+void
+ConnectionPool::remove(const PoolIt& it)
+{
+       destroy(it->conn);
+       pool_.erase(it);
+}
+
+
 //// remove_old_connections ////////////////////////////////////////////
 // Remove connections that were last used too long ago.
 
@@ -151,8 +162,7 @@
 
        PoolIt it = pool_.begin();
        while ((it = std::find_if(it, pool_.end(), too_old)) != pool_.end()) {
-               destroy(it->conn);
-               pool_.erase(it++);
+               remove(it++);
        }
 }
 

Modified: trunk/lib/cpool.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/cpool.h?rev=2505&r1=2504&r2=2505&view=diff
==============================================================================
--- trunk/lib/cpool.h (original)
+++ trunk/lib/cpool.h Sun Apr 26 04:59:41 2009
@@ -188,6 +188,7 @@
 
        //// Internal support functions
        Connection* find_mru();
+       void remove(const PoolIt& it);
        void remove_old_connections();
 
        //// Internal data


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to