Debian Codegraph @

docs/programmer_reference/stl_txn_usage.html

raw symbols SCIP
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 xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Using transactions in dbstl</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="stl_db_advanced_usage.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 7. Standard Template Library API</th>
26 <td width="20%" align="right"> <a accesskey="n" href="stl_mt_usage.html">Next</a></td>
27 </tr>
28 </table>
29 <hr />
30 </div>
31 <div class="sect1" lang="en" xml:lang="en">
32 <div class="titlepage">
33 <div>
34 <div>
35 <h2 class="title" style="clear: both"><a id="stl_txn_usage"></a>Using transactions in dbstl</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 When using transactions with dbstl, you must call the dbstl transaction
41 functions instead of the corresponding methods from the Berkeley DB C
42 or C++ transaction API. That is, you must use
43 <code class="methodname">dbstl::begin_txn()</code>,
44 <code class="methodname">dbstl::commit_txn()</code> and
45 <code class="methodname">dbstl::abort_txn()</code> in order to
46 begin/commit/abort transactions.
47 </p>
48 <p>
49 A container can be configured to use auto commit by setting the
50 <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
51 opened. In this case, any container method that supports auto commit
52 will automatically form an independent transaction if the method
53 is not in an external transactional context; Otherwise,
54 the operation will become part of that transaction.
55
56 </p>
57 <p>
58 You can configure the flags used internally by dbstl when it is
59 creating and committing these independent transactions required by auto
60 commit. To do so, use the
61 <code class="methodname">db_container::set_txn_begin_flags()</code> and/or
62 <code class="methodname">db_container::set_commit_flags()</code> methods.
63 </p>
64 <p>
65 When a transaction is committed or aborted, dbstl will automatically
66 close any cursors opened for use by the transaction. For this reason,
67 any iterators opened within the transaction context should not be used
68 after the transaction commits or aborts.
69 </p>
70 <p>
71 You can use nested transactions explicitly and externally, by calling
72 <code class="methodname">dbstl::begin_txn()</code> in a context already
73 operating under the protection of a transaction. But you can not
74 designate which transaction is the parent transaction. The parent
75 transaction is automatically the most recently created and unresolved
76 transaction in current thread.
77 </p>
78 <p>
79 It is also acceptable to use explicit transactions in a container
80 configured for auto commit. The operation performed by the method will
81 become part of the provided external transaction.
82 </p>
83 <p>
84 Finally, transactions and iterators cannot be shared among multiple
85 threads. That is, they are not free-threaded, or thread-safe.
86 </p>
87 </div>
88 <div class="navfooter">
89 <hr />
90 <table width="100%" summary="Navigation footer">
91 <tr>
92 <td width="40%" align="left"><a accesskey="p" href="stl_db_advanced_usage.html">Prev</a> </td>
93 <td width="20%" align="center">
94 <a accesskey="u" href="stl.html">Up</a>
95 </td>
96 <td width="40%" align="right"> <a accesskey="n" href="stl_mt_usage.html">Next</a></td>
97 </tr>
98 <tr>
99 <td width="40%" align="left" valign="top">Using advanced Berkeley DB features with dbstl </td>
100 <td width="20%" align="center">
101 <a accesskey="h" href="index.html">Home</a>
102 </td>
103 <td width="40%" align="right" valign="top"> Using dbstl in multithreaded applications</td>
104 </tr>
105 </table>
106 </div>
107 </body>
108 </html>