1<!--$Id: mutex_alloc.so,v 10.3 2007/09/21 20:06:03 bostic 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: DbEnv::mutex_alloc</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> 13<b>DbEnv::mutex_alloc</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::mutex_alloc(u_int32_t flags, db_mutex_t *mutexp); 26</pre></b> 27<hr size=1 noshade> 28<b>Description: DbEnv::mutex_alloc</b> 29<p>The DbEnv::mutex_alloc method allocates a mutex and returns a reference to 30it into the memory specified by <b>mutexp</b>.</p> 31<p>The DbEnv::mutex_alloc method may not be called before the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is called.</p> 32<p>The DbEnv::mutex_alloc method 33either returns a non-zero error value 34or throws an exception that encapsulates a non-zero error value on 35failure, and returns 0 on success. 36</p> 37<b>Parameters</b> <br> 38 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 39the following value: 40<br> 41<b><a name="DB_MUTEX_PROCESS_ONLY">DB_MUTEX_PROCESS_ONLY</a></b><ul compact><li>The mutex is associated with a single process. The <a href="../api_cxx/env_failchk.html">DbEnv::failchk</a> method 42will release mutexes held by any process which has exited.</ul> 43<b><a name="DB_MUTEX_SELF_BLOCK">DB_MUTEX_SELF_BLOCK</a></b><ul compact><li>The mutex must be self-blocking. That is, if a thread of control locks 44the mutex and then attempts to lock the mutex again, the thread of 45control will block until another thread of control releases the original 46lock on the mutex, allowing the original thread of control to lock the 47mutex the second time. Attempting to re-acquire a mutex for which the 48DB_MUTEX_SELF_BLOCK flag was not specified will result in 49undefined behavior.</ul> 50<br></ul> 51 <b>mutexp</b><ul compact><li>The <b>mutexp</b> parameter references memory into which 52 the mutex reference is copied.</ul> 53<br> 54<br><b>Errors</b> 55<p>The DbEnv::mutex_alloc method 56may fail and throw 57<a href="../api_cxx/except_class.html">DbException</a>, 58encapsulating one of the following non-zero errors, or return one of 59the following non-zero errors:</p> 60<br> 61<b>EINVAL</b><ul compact><li>An 62invalid flag value or parameter was specified.</ul> 63<br> 64<hr size=1 noshade> 65<br><b>Class</b> 66<a href="../api_cxx/env_class.html">DbEnv</a> 67<br><b>See Also</b> 68<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a> 69</tt> 70<table width="100%"><tr><td><br></td><td align=right> 71<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 72</td></tr></table> 73<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 74</body> 75</html> 76