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>DbEnv::mutex_set_align()</title> 7 <link rel="stylesheet" href="apiReference.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 C++ API Reference" /> 10 <link rel="up" href="mutex.html" title="Chapter 10. Mutex Methods" /> 11 <link rel="prev" href="mutexlock.html" title="DbEnv::mutex_lock()" /> 12 <link rel="next" href="mutexset_increment.html" title="DbEnv::mutex_set_increment()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::mutex_set_align()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="mutexlock.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 10. 23 Mutex Methods 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="mutexset_increment.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="mutexset_align"></a>DbEnv::mutex_set_align()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::mutex_set_align(u_int32_t align); </pre> 42 <p> 43 Set the mutex alignment, in bytes. 44 </p> 45 <p> 46 It is sometimes advantageous to align mutexes on specific byte 47 boundaries in order to minimize cache line collisions. The 48 <code class="methodname">DbEnv::mutex_set_align()</code> method specifies an alignment for mutexes 49 allocated by Berkeley DB. 50 </p> 51 <p> 52 The database environment's mutex alignment may also be configured 53 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 54 syntax of the entry in that file is a single line with the string 55 "mutex_set_align", one or more whitespace characters, and the mutex 56 alignment in bytes. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 57 read when the database environment is opened, it will silently 58 overrule configuration done before that time. 59 </p> 60 <p> 61 The <code class="methodname">DbEnv::mutex_set_align()</code> method configures a database 62 environment, not only operations performed using the specified 63 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 64 </p> 65 <p> 66 The <code class="methodname">DbEnv::mutex_set_align()</code> method may not be called after the 67 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is 68 called. If the database environment already exists when 69 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> is called, the 70 information specified to <code class="methodname">DbEnv::mutex_set_align()</code> will be ignored. 71 </p> 72 <p> 73 The <code class="methodname">DbEnv::mutex_set_align()</code> <span> 74 75 <span> 76 method either returns a non-zero error value or throws an 77 exception that encapsulates a non-zero error value on 78 failure, and returns 0 on success. 79 </span> 80 </span> 81 </p> 82 <div class="sect2" lang="en" xml:lang="en"> 83 <div class="titlepage"> 84 <div> 85 <div> 86 <h3 class="title"><a id="id1699023"></a>Parameters</h3> 87 </div> 88 </div> 89 </div> 90 <div class="sect3" lang="en" xml:lang="en"> 91 <div class="titlepage"> 92 <div> 93 <div> 94 <h4 class="title"><a id="id1699033"></a>align</h4> 95 </div> 96 </div> 97 </div> 98 <p> 99 The <span class="bold"><strong>align</strong></span> parameter is the mutex 100 alignment, in bytes. The mutex alignment must be a power-of-two. 101 </p> 102 </div> 103 </div> 104 <div class="sect2" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h3 class="title"><a id="id1699190"></a>Errors</h3> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <code class="methodname">DbEnv::mutex_set_align()</code> <span> 114 115 <span> 116 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 117 exception, encapsulating one of the following non-zero errors, or return one 118 of the following non-zero errors: 119 </span> 120 </span> 121 </p> 122 <div class="sect3" lang="en" xml:lang="en"> 123 <div class="titlepage"> 124 <div> 125 <div> 126 <h4 class="title"><a id="id1698986"></a>EINVAL</h4> 127 </div> 128 </div> 129 </div> 130 <p> 131 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 132 was called; or if an invalid flag value or parameter was specified. 133 </p> 134 </div> 135 </div> 136 <div class="sect2" lang="en" xml:lang="en"> 137 <div class="titlepage"> 138 <div> 139 <div> 140 <h3 class="title"><a id="id1698917"></a>Class</h3> 141 </div> 142 </div> 143 </div> 144 <p> 145 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 146 </p> 147 </div> 148 <div class="sect2" lang="en" xml:lang="en"> 149 <div class="titlepage"> 150 <div> 151 <div> 152 <h3 class="title"><a id="id1698921"></a>See Also</h3> 153 </div> 154 </div> 155 </div> 156 <p> 157 <a class="xref" href="mutex.html#mutexlist" title="Mutex Methods">Mutex Methods</a> 158 </p> 159 </div> 160 </div> 161 <div class="navfooter"> 162 <hr /> 163 <table width="100%" summary="Navigation footer"> 164 <tr> 165 <td width="40%" align="left"><a accesskey="p" href="mutexlock.html">Prev</a> </td> 166 <td width="20%" align="center"> 167 <a accesskey="u" href="mutex.html">Up</a> 168 </td> 169 <td width="40%" align="right"> <a accesskey="n" href="mutexset_increment.html">Next</a></td> 170 </tr> 171 <tr> 172 <td width="40%" align="left" valign="top">DbEnv::mutex_lock() </td> 173 <td width="20%" align="center"> 174 <a accesskey="h" href="index.html">Home</a> 175 </td> 176 <td width="40%" align="right" valign="top"> DbEnv::mutex_set_increment()</td> 177 </tr> 178 </table> 179 </div> 180 </body> 181</html> 182