1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MySQL++ Reference Manual</title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MySQL++: mysqlpp::ConnectionPool Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">MySQL++
 <span id="projectnumber">3.2.5</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><b>mysqlpp</b></li><li class="navelem"><a class="el" href="classmysqlpp_1_1ConnectionPool.html">ConnectionPool</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> |
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pro-methods">Protected Member Functions</a> |
<a href="classmysqlpp_1_1ConnectionPool-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">mysqlpp::ConnectionPool Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p>Manages a pool of connections for programs that need more than one <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object at a time, but can't predict how many they need in advance.
<a href="classmysqlpp_1_1ConnectionPool.html#details">More...</a></p>
<p><code>#include <<a class="el" href="cpool_8h_source.html">cpool.h</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:acc1262db33d586284651825ff076a8d7"><td class="memItemLeft" align="right" valign="top"><a id="acc1262db33d586284651825ff076a8d7"></a>
 </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#acc1262db33d586284651825ff076a8d7">ConnectionPool</a> ()</td></tr>
<tr class="memdesc:acc1262db33d586284651825ff076a8d7"><td class="mdescLeft"> </td><td class="mdescRight">Create empty pool. <br /></td></tr>
<tr class="separator:acc1262db33d586284651825ff076a8d7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2cee954229416e24da07f5e208b35b09"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a2cee954229416e24da07f5e208b35b09">~ConnectionPool</a> ()</td></tr>
<tr class="memdesc:a2cee954229416e24da07f5e208b35b09"><td class="mdescLeft"> </td><td class="mdescRight">Destroy object. <a href="#a2cee954229416e24da07f5e208b35b09">More...</a><br /></td></tr>
<tr class="separator:a2cee954229416e24da07f5e208b35b09"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac7f3bd443b9a70fb21ce86fa7ced880e"><td class="memItemLeft" align="right" valign="top"><a id="ac7f3bd443b9a70fb21ce86fa7ced880e"></a>
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#ac7f3bd443b9a70fb21ce86fa7ced880e">empty</a> () const</td></tr>
<tr class="memdesc:ac7f3bd443b9a70fb21ce86fa7ced880e"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if pool is empty. <br /></td></tr>
<tr class="separator:ac7f3bd443b9a70fb21ce86fa7ced880e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a4f9844f2c57c9f51f1b5a2b8a996ee15"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a4f9844f2c57c9f51f1b5a2b8a996ee15">exchange</a> (const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> *pc)</td></tr>
<tr class="memdesc:a4f9844f2c57c9f51f1b5a2b8a996ee15"><td class="mdescLeft"> </td><td class="mdescRight">Return a defective connection to the pool and get a new one back. <a href="#a4f9844f2c57c9f51f1b5a2b8a996ee15">More...</a><br /></td></tr>
<tr class="separator:a4f9844f2c57c9f51f1b5a2b8a996ee15"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:acbf56ee86ef66b3ebdf02adde5908776"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776">grab</a> ()</td></tr>
<tr class="memdesc:acbf56ee86ef66b3ebdf02adde5908776"><td class="mdescLeft"> </td><td class="mdescRight">Grab a free connection from the pool. <a href="#acbf56ee86ef66b3ebdf02adde5908776">More...</a><br /></td></tr>
<tr class="separator:acbf56ee86ef66b3ebdf02adde5908776"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac51a7a63ce4d8825c3f7b05f4b8bfe68"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#ac51a7a63ce4d8825c3f7b05f4b8bfe68">release</a> (const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> *pc)</td></tr>
<tr class="memdesc:ac51a7a63ce4d8825c3f7b05f4b8bfe68"><td class="mdescLeft"> </td><td class="mdescRight">Return a connection to the pool. <a href="#ac51a7a63ce4d8825c3f7b05f4b8bfe68">More...</a><br /></td></tr>
<tr class="separator:ac51a7a63ce4d8825c3f7b05f4b8bfe68"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aae75febe979da2d4a3335c46438f3d33"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#aae75febe979da2d4a3335c46438f3d33">remove</a> (const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> *pc)</td></tr>
<tr class="memdesc:aae75febe979da2d4a3335c46438f3d33"><td class="mdescLeft"> </td><td class="mdescRight">Removes the given connection from the pool. <a href="#aae75febe979da2d4a3335c46438f3d33">More...</a><br /></td></tr>
<tr class="separator:aae75febe979da2d4a3335c46438f3d33"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aac4d50bb5c603efec4b8d7e0a3e8a164"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#aac4d50bb5c603efec4b8d7e0a3e8a164">safe_grab</a> ()</td></tr>
<tr class="memdesc:aac4d50bb5c603efec4b8d7e0a3e8a164"><td class="mdescLeft"> </td><td class="mdescRight">Grab a free connection from the pool, testing that it's connected before returning it. <a href="#aac4d50bb5c603efec4b8d7e0a3e8a164">More...</a><br /></td></tr>
<tr class="separator:aac4d50bb5c603efec4b8d7e0a3e8a164"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac410ed5cb3032aed048fb3a275629654"><td class="memItemLeft" align="right" valign="top"><a id="ac410ed5cb3032aed048fb3a275629654"></a>
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#ac410ed5cb3032aed048fb3a275629654">shrink</a> ()</td></tr>
<tr class="memdesc:ac410ed5cb3032aed048fb3a275629654"><td class="mdescLeft"> </td><td class="mdescRight">Remove all unused connections from the pool. <br /></td></tr>
<tr class="separator:ac410ed5cb3032aed048fb3a275629654"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a981e1b1715de2daea9f6b10bdcbb5915"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a981e1b1715de2daea9f6b10bdcbb5915">clear</a> (bool all=true)</td></tr>
<tr class="memdesc:a981e1b1715de2daea9f6b10bdcbb5915"><td class="mdescLeft"> </td><td class="mdescRight">Drains the pool, freeing all allocated memory. <a href="#a981e1b1715de2daea9f6b10bdcbb5915">More...</a><br /></td></tr>
<tr class="separator:a981e1b1715de2daea9f6b10bdcbb5915"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af755c7e11b92bbab0e88ab3e9c88f0fd"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#af755c7e11b92bbab0e88ab3e9c88f0fd">create</a> ()=0</td></tr>
<tr class="memdesc:af755c7e11b92bbab0e88ab3e9c88f0fd"><td class="mdescLeft"> </td><td class="mdescRight">Create a new connection. <a href="#af755c7e11b92bbab0e88ab3e9c88f0fd">More...</a><br /></td></tr>
<tr class="separator:af755c7e11b92bbab0e88ab3e9c88f0fd"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3dae30e24dd6967e4e427fa69dbc2105"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a3dae30e24dd6967e4e427fa69dbc2105">destroy</a> (<a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> *)=0</td></tr>
<tr class="memdesc:a3dae30e24dd6967e4e427fa69dbc2105"><td class="mdescLeft"> </td><td class="mdescRight">Destroy a connection. <a href="#a3dae30e24dd6967e4e427fa69dbc2105">More...</a><br /></td></tr>
<tr class="separator:a3dae30e24dd6967e4e427fa69dbc2105"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8a5ba414a5b02c48d64501c25b64a656"><td class="memItemLeft" align="right" valign="top">virtual unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a8a5ba414a5b02c48d64501c25b64a656">max_idle_time</a> ()=0</td></tr>
<tr class="memdesc:a8a5ba414a5b02c48d64501c25b64a656"><td class="mdescLeft"> </td><td class="mdescRight">Returns the maximum number of seconds a connection is able to remain idle before it is dropped. <a href="#a8a5ba414a5b02c48d64501c25b64a656">More...</a><br /></td></tr>
<tr class="separator:a8a5ba414a5b02c48d64501c25b64a656"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a852e802aa80a2e608926760a1d9b4591"><td class="memItemLeft" align="right" valign="top"><a id="a852e802aa80a2e608926760a1d9b4591"></a>
size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classmysqlpp_1_1ConnectionPool.html#a852e802aa80a2e608926760a1d9b4591">size</a> () const</td></tr>
<tr class="memdesc:a852e802aa80a2e608926760a1d9b4591"><td class="mdescLeft"> </td><td class="mdescRight">Returns the current size of the internal connection pool. <br /></td></tr>
<tr class="separator:a852e802aa80a2e608926760a1d9b4591"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Manages a pool of connections for programs that need more than one <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object at a time, but can't predict how many they need in advance. </p>
<p>This class is useful in programs that need to make multiple simultaneous queries on the database; this requires multiple <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> objects due to a hard limitation of the underlying C API. <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> pools are most useful in multithreaded programs, but it can be helpful to have one in a single-threaded program as well. Sometimes it's necessary to get more data from the server while in the middle of processing data from an earlier query; this requires multiple connections. Whether you use a pool or manage connections yourself is up to you, but realize that this class takes care of a lot of subtle details for you that aren't obvious.</p>
<p>The pool's policy for connection reuse is to always return the <em>most</em> recently used connection that's not being used right now. This ensures that excess connections don't hang around any longer than they must. If the pool were to return the <em>least</em> recently used connection, it would be likely to result in a large pool of sparsely used connections because we'd keep resetting the last-used time of whichever connection is least recently used at that moment. </p>
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a id="a2cee954229416e24da07f5e208b35b09"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2cee954229416e24da07f5e208b35b09">◆ </a></span>~ConnectionPool()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual mysqlpp::ConnectionPool::~ConnectionPool </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Destroy object. </p>
<p>If the pool raises an assertion on destruction, it means our subclass isn't calling <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a981e1b1715de2daea9f6b10bdcbb5915" title="Drains the pool, freeing all allocated memory.">clear()</a> in its dtor as it should. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a981e1b1715de2daea9f6b10bdcbb5915"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a981e1b1715de2daea9f6b10bdcbb5915">◆ </a></span>clear()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void mysqlpp::ConnectionPool::clear </td>
<td>(</td>
<td class="paramtype">bool </td>
<td class="paramname"><em>all</em> = <code>true</code></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Drains the pool, freeing all allocated memory. </p>
<p>A derived class must call this in its dtor to avoid leaking all <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> objects still in existence. We can't do it up at this level because this class's dtor can't call our subclass's <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a3dae30e24dd6967e4e427fa69dbc2105" title="Destroy a connection.">destroy()</a> method.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">all</td><td>if true, remove all connections, even those in use </td></tr>
</table>
</dd>
</dl>
<p class="reference">References <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aae75febe979da2d4a3335c46438f3d33">remove()</a>.</p>
</div>
</div>
<a id="af755c7e11b92bbab0e88ab3e9c88f0fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af755c7e11b92bbab0e88ab3e9c88f0fd">◆ </a></span>create()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a>* mysqlpp::ConnectionPool::create </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Create a new connection. </p>
<p>Subclasses must override this.</p>
<p>Essentially, this method lets your code tell <a class="el" href="classmysqlpp_1_1ConnectionPool.html" title="Manages a pool of connections for programs that need more than one Connection object at a time,...">ConnectionPool</a> what server to connect to, what login parameters to use, what connection options to enable, etc. <a class="el" href="classmysqlpp_1_1ConnectionPool.html" title="Manages a pool of connections for programs that need more than one Connection object at a time,...">ConnectionPool</a> can't know any of this without your help.</p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">A</td><td>connected <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object </td></tr>
</table>
</dd>
</dl>
<p class="reference">Referenced by <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776">grab()</a>.</p>
</div>
</div>
<a id="a3dae30e24dd6967e4e427fa69dbc2105"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3dae30e24dd6967e4e427fa69dbc2105">◆ </a></span>destroy()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void mysqlpp::ConnectionPool::destroy </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Destroy a connection. </p>
<p>Subclasses must override this.</p>
<p>This is for destroying the objects returned by <a class="el" href="classmysqlpp_1_1ConnectionPool.html#af755c7e11b92bbab0e88ab3e9c88f0fd" title="Create a new connection.">create()</a>. Because we can't know what the derived class did to create the connection we can't reliably know how to destroy it. </p>
</div>
</div>
<a id="a4f9844f2c57c9f51f1b5a2b8a996ee15"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4f9844f2c57c9f51f1b5a2b8a996ee15">◆ </a></span>exchange()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * mysqlpp::ConnectionPool::exchange </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td>
<td class="paramname"><em>pc</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Return a defective connection to the pool and get a new one back. </p>
<p>Call this on receiving a <a class="el" href="classmysqlpp_1_1BadQuery.html" title="Exception thrown when the database server encounters a problem while processing your query.">BadQuery</a> exception, with errnum() equal to CR_SERVER_GONE_ERROR. It means the server was restarted or otherwise dropped your connection to it, so the <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object is no longer usable. You can avoid the need to use this by setting the <a class="el" href="classmysqlpp_1_1ReconnectOption.html" title="Enable automatic reconnection to server.">ReconnectOption</a> in your <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776" title="Grab a free connection from the pool.">grab()</a> override, but perhaps there are other reasons to need to exchange a bad connection for a good one.</p>
<p>This function wraps <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776" title="Grab a free connection from the pool.">grab()</a>, not <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aac4d50bb5c603efec4b8d7e0a3e8a164" title="Grab a free connection from the pool, testing that it's connected before returning it.">safe_grab()</a>, even though that could return another dead connection. The assumption is that if your code is smart enough to detect one bad connection, it should be smart enough to detect a whole string of them. Worst case, the whole pool is bad – remote server went away – and we have to empty the pool and start re-filling it.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pc</td><td>pointer to a <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object to be returned to the pool and marked as unused.</td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">a</td><td>pointer to a different <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object; not guaranteed to still be connected! </td></tr>
</table>
</dd>
</dl>
<p class="reference">References <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776">grab()</a>, and <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aae75febe979da2d4a3335c46438f3d33">remove()</a>.</p>
</div>
</div>
<a id="acbf56ee86ef66b3ebdf02adde5908776"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acbf56ee86ef66b3ebdf02adde5908776">◆ </a></span>grab()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * mysqlpp::ConnectionPool::grab </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Grab a free connection from the pool. </p>
<p>This method creates a new connection if an unused one doesn't exist, and destroys any that have remained unused for too long. If there is more than one free connection, we return the most recently used one; this allows older connections to die off over time when the caller's need for connections decreases.</p>
<p>Do not delete the returned pointer. This object manages the lifetime of connection objects it creates.</p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">a</td><td>pointer to the connection </td></tr>
</table>
</dd>
</dl>
<p class="reference">References <a class="el" href="classmysqlpp_1_1ConnectionPool.html#af755c7e11b92bbab0e88ab3e9c88f0fd">create()</a>.</p>
<p class="reference">Referenced by <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a4f9844f2c57c9f51f1b5a2b8a996ee15">exchange()</a>, and <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aac4d50bb5c603efec4b8d7e0a3e8a164">safe_grab()</a>.</p>
</div>
</div>
<a id="a8a5ba414a5b02c48d64501c25b64a656"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8a5ba414a5b02c48d64501c25b64a656">◆ </a></span>max_idle_time()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual unsigned int mysqlpp::ConnectionPool::max_idle_time </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the maximum number of seconds a connection is able to remain idle before it is dropped. </p>
<p>Subclasses must override this as it encodes a policy issue, something that MySQL++ can't declare by fiat.</p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">number</td><td>of seconds before an idle connection is destroyed due to lack of use </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="ac51a7a63ce4d8825c3f7b05f4b8bfe68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac51a7a63ce4d8825c3f7b05f4b8bfe68">◆ </a></span>release()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void mysqlpp::ConnectionPool::release </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td>
<td class="paramname"><em>pc</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Return a connection to the pool. </p>
<p>Marks the connection as no longer in use.</p>
<p>The pool updates the last-used time of a connection only on release, on the assumption that it was used just prior. There's nothing forcing you to do it this way: your code is free to delay releasing idle connections as long as it likes. You want to avoid this because it will make the pool perform poorly; if it doesn't know approximately how long a connection has really been idle, it can't make good judgements about when to remove it from the pool.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pc</td><td>pointer to a <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object to be returned to the pool and marked as unused. </td></tr>
</table>
</dd>
</dl>
<p class="reference">Referenced by <a class="el" href="classmysqlpp_1_1ScopedConnection.html#ab8b21eb30678cb0530d6dbc1eed38bef">mysqlpp::ScopedConnection::~ScopedConnection()</a>.</p>
</div>
</div>
<a id="aae75febe979da2d4a3335c46438f3d33"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aae75febe979da2d4a3335c46438f3d33">◆ </a></span>remove()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mysqlpp::ConnectionPool::remove </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * </td>
<td class="paramname"><em>pc</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Removes the given connection from the pool. </p>
<p>If you mean to simply return a connection to the pool after you're finished using it, call <a class="el" href="classmysqlpp_1_1ConnectionPool.html#ac51a7a63ce4d8825c3f7b05f4b8bfe68" title="Return a connection to the pool.">release()</a> instead. This method is primarily for error handling: you somehow have figured out that the connection is defective, so want it destroyed and removed from the pool. If you also want a different connection to retry your operation on, call <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a4f9844f2c57c9f51f1b5a2b8a996ee15" title="Return a defective connection to the pool and get a new one back.">exchange()</a> instead.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pc</td><td>pointer to a <a class="el" href="classmysqlpp_1_1Connection.html" title="Manages the connection to the database server.">Connection</a> object to be removed from the pool and destroyed </td></tr>
</table>
</dd>
</dl>
<p class="reference">Referenced by <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a981e1b1715de2daea9f6b10bdcbb5915">clear()</a>, <a class="el" href="classmysqlpp_1_1ConnectionPool.html#a4f9844f2c57c9f51f1b5a2b8a996ee15">exchange()</a>, and <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aac4d50bb5c603efec4b8d7e0a3e8a164">safe_grab()</a>.</p>
</div>
</div>
<a id="aac4d50bb5c603efec4b8d7e0a3e8a164"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aac4d50bb5c603efec4b8d7e0a3e8a164">◆ </a></span>safe_grab()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classmysqlpp_1_1Connection.html">Connection</a> * mysqlpp::ConnectionPool::safe_grab </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Grab a free connection from the pool, testing that it's connected before returning it. </p>
<p>This is just a wrapper around <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776" title="Grab a free connection from the pool.">grab()</a>, <a class="el" href="classmysqlpp_1_1Connection.html#ac1dbc411f7ab1debbabe241561fe4091" title=""Pings" the database server">Connection::ping()</a> and <a class="el" href="classmysqlpp_1_1ConnectionPool.html#ac51a7a63ce4d8825c3f7b05f4b8bfe68" title="Return a connection to the pool.">release()</a>, and is thus less efficient than <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776" title="Grab a free connection from the pool.">grab()</a>. Use it only when it's possible for MySQL server connections to go away unexpectedly, such as when the DB server can be restarted out from under your application.</p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">a</td><td>pointer to the connection </td></tr>
</table>
</dd>
</dl>
<p class="reference">References <a class="el" href="classmysqlpp_1_1ConnectionPool.html#acbf56ee86ef66b3ebdf02adde5908776">grab()</a>, and <a class="el" href="classmysqlpp_1_1ConnectionPool.html#aae75febe979da2d4a3335c46438f3d33">remove()</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="cpool_8h_source.html">cpool.h</a></li>
<li>cpool.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Jul 21 2019 05:32:21 for MySQL++ by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
|