1<!--$Id: faq.so,v 10.3 2002/12/10 23:41:42 mjc Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Programmer notes FAQ</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Programmer Notes</dl></b></td> 13<td align=right><a href="../program/runtime.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/intro.html"><img src="../../images/next.gif" alt="Next"></a> 14</td></tr></table> 15<p align=center><b>Programmer notes FAQ</b></p> 16<ol> 17<a name="2"><!--meow--></a> 18<p><li><b>What priorities should threads/tasks executing Berkeley DB functions 19be given?</b> 20<p>Tasks executing Berkeley DB functions should have the same, or roughly 21equivalent, system priorities. For example, it can be dangerous to give 22tasks of control performing checkpoints a lower priority than tasks of 23control doing database lookups, and starvation can sometimes result.</p> 24<p><li><b>Why isn't the C++ API exception safe?</b> 25<p>The Berkeley DB C++ API is a thin wrapper around the C API that maps most 26return values to exceptions, and gives the C++ handles the same 27lifecycles as their C counterparts. One consequence is that if an 28exception occurs while a cursor or transaction handle is open, the 29application must explicitly close the cursor or abort the transaction.</p> 30<p>Applications can be simplified and bugs avoided by creating wrapper 31classes around <a href="../../api_c/dbc_class.html">DBC</a> and <a href="../../api_c/txn_class.html">DB_TXN</a> that call the appropriate 32cleanup method in the wrapper's destructor. By creating an instance 33of the wrappers on the stack, C++ scoping rules will ensure that the 34destructor is called before exception handling unrolls the block that 35contains the wrapper object.</p> 36</ol> 37<table width="100%"><tr><td><br></td><td align=right><a href="../program/runtime.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../lock/intro.html"><img src="../../images/next.gif" alt="Next"></a> 38</td></tr></table> 39<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 40</body> 41</html> 42