• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Using transactions in dbstl</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10    <link rel="up" href="stl.html" title="Chapter��7.��Standard Template Library API" />
11    <link rel="prev" href="stl_db_advanced_usage.html" title="Using advanced Berkeley DB features with dbstl" />
12    <link rel="next" href="stl_mt_usage.html" title="Using dbstl in multithreaded applications" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Using transactions in dbstl</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="stl_db_advanced_usage.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��7.��Standard Template Library API</th>
23          <td width="20%" align="right">��<a accesskey="n" href="stl_mt_usage.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="sect1" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title" style="clear: both"><a id="stl_txn_usage"></a>Using transactions in dbstl</h2>
33          </div>
34        </div>
35      </div>
36      <p>
37    When using transactions with dbstl, you must call the dbstl transaction
38    functions instead of the corresponding methods from the Berkeley DB C
39    or C++ transaction API. That is, you must use
40    <code class="methodname">dbstl::begin_txn()</code>,
41    <code class="methodname">dbstl::commit_txn()</code> and
42    <code class="methodname">dbstl::abort_txn()</code> in order to
43    begin/commit/abort transactions.
44</p>
45      <p>
46    A container can be configured to use auto commit by setting the
47    <a href="../api_reference/C/envset_flags.html#envset_flags_DB_AUTO_COMMIT" class="olink">DB_AUTO_COMMIT</a> flag when the environment or database handle is
48    opened. In this case, any container method that supports auto commit
49    will automatically form an independent transaction if the method 
50    is not in an external transactional context; Otherwise,
51    the operation will become part of that transaction.
52    
53</p>
54      <p>
55    You can configure the flags used internally by dbstl when it is
56    creating and committing these independent transactions required by auto
57    commit. To do so, use the
58    <code class="methodname">db_container::set_txn_begin_flags()</code> and/or
59    <code class="methodname">db_container::set_commit_flags()</code> methods.
60</p>
61      <p>
62    When a transaction is committed or aborted, dbstl will automatically
63    close any cursors opened for use by the transaction. For this reason,
64    any iterators opened within the transaction context should not be used
65    after the transaction commits or aborts. 
66</p>
67      <p>
68    You can use nested transactions explicitly and externally, by calling
69    <code class="methodname">dbstl::begin_txn()</code> in a context already
70    operating under the protection of a transaction. But you can not
71    designate which transaction is the parent transaction. The parent
72    transaction is automatically the most recently created and unresolved
73    transaction in current thread.
74</p>
75      <p>
76    It is also acceptable to use explicit transactions in a container
77    configured for auto commit.  The operation performed by the method will
78    become part of the provided external transaction.
79</p>
80      <p>
81    Finally, transactions and iterators cannot be shared among multiple
82    threads. That is, they are not free-threaded, or thread-safe.
83</p>
84    </div>
85    <div class="navfooter">
86      <hr />
87      <table width="100%" summary="Navigation footer">
88        <tr>
89          <td width="40%" align="left"><a accesskey="p" href="stl_db_advanced_usage.html">Prev</a>��</td>
90          <td width="20%" align="center">
91            <a accesskey="u" href="stl.html">Up</a>
92          </td>
93          <td width="40%" align="right">��<a accesskey="n" href="stl_mt_usage.html">Next</a></td>
94        </tr>
95        <tr>
96          <td width="40%" align="left" valign="top">Using advanced Berkeley DB features with dbstl��</td>
97          <td width="20%" align="center">
98            <a accesskey="h" href="index.html">Home</a>
99          </td>
100          <td width="40%" align="right" valign="top">��Using dbstl in multithreaded applications</td>
101        </tr>
102      </table>
103    </div>
104  </body>
105</html>
106