Debian Codegraph @

docs/api_reference/CXX/lockvec.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>DbEnv::lock_vec()</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="lock.html" title="Chapter 7.  The DbLock Handle" />
11 <link rel="prev" href="lockstat_print.html" title="DbEnv::lock_stat_print()" />
12 <link rel="next" href="lsn.html" title="Chapter 8.  The DbLsn Handle" />
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">DbEnv::lock_vec()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="lockstat_print.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 7. 
26 The DbLock Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="lsn.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="lockvec"></a>DbEnv::lock_vec()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbEnv::lock_vec(u_int32_t locker, u_int32_t flags,
45 DB_LOCKREQ list[], int nlist, DB_LOCKREQ **elistp);</pre>
46 <p>
47 The <code class="methodname">DbEnv::lock_vec()</code> method atomically obtains and releases one or
48 more locks from the lock table. The <code class="methodname">DbEnv::lock_vec()</code> method is
49 intended to support acquisition or trading of multiple locks under one
50 lock table semaphore, as is needed for lock coupling or in
51 multigranularity locking for lock escalation.
52 </p>
53 <p>
54 If any of the requested locks cannot be acquired, or any of the locks
55 to be released cannot be released, the operations before the failing
56 operation are guaranteed to have completed successfully, and
57 <code class="methodname">DbEnv::lock_vec()</code> returns a non-zero value. In addition, if
58 <span class="bold"><strong>elistp</strong></span> is not NULL, it is set to
59 point to the DB_LOCKREQ entry that was being processed when the error
60 occurred.
61 </p>
62 <p>
63 Unless otherwise specified, the <code class="methodname">DbEnv::lock_vec()</code> <span>
64
65 <span>
66 method either returns a non-zero error value or throws an
67 exception that encapsulates a non-zero error value on
68 failure, and returns 0 on success.
69 </span>
70 </span>
71 </p>
72 <div class="sect2" lang="en" xml:lang="en">
73 <div class="titlepage">
74 <div>
75 <div>
76 <h3 class="title"><a id="idp8171712"></a>Parameters</h3>
77 </div>
78 </div>
79 </div>
80 <div class="sect3" lang="en" xml:lang="en">
81 <div class="titlepage">
82 <div>
83 <div>
84 <h4 class="title"><a id="idp8183208"></a>locker</h4>
85 </div>
86 </div>
87 </div>
88 <p>
89 The <span class="bold"><strong>locker</strong></span> parameter is an unsigned
90 32-bit integer quantity. It represents the entity requesting or
91 releasing the lock.
92 </p>
93 </div>
94 <div class="sect3" lang="en" xml:lang="en">
95 <div class="titlepage">
96 <div>
97 <div>
98 <h4 class="title"><a id="idp8164768"></a>flags</h4>
99 </div>
100 </div>
101 </div>
102 <p>
103 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
104 or the following value:
105 </p>
106 <div class="itemizedlist">
107 <ul type="disc">
108 <li>
109 <p><a id="vec_DB_LOCK_NOWAIT"></a>
110 <code class="literal">DB_LOCK_NOWAIT</code>
111 </p>
112 <p>
113 If a lock cannot be granted because the requested lock conflicts with
114 an existing lock, return DB_LOCK_NOTGRANTED immediately instead of
115 waiting for the lock to become available. In this case, if non-NULL,
116 <span class="bold"><strong>elistp</strong></span> identifies the request that
117 was not granted.
118 </p>
119 </li>
120 </ul>
121 </div>
122 </div>
123 <div class="sect3" lang="en" xml:lang="en">
124 <div class="titlepage">
125 <div>
126 <div>
127 <h4 class="title"><a id="idp8187600"></a>list</h4>
128 </div>
129 </div>
130 </div>
131 <p>
132 The <span class="bold"><strong>list</strong></span> array provided to
133 <code class="methodname">DbEnv::lock_vec()</code> is typedef'd as DB_LOCKREQ.
134 </p>
135 <p>
136 To ensure compatibility with future releases of Berkeley DB, all
137 fields of the DB_LOCKREQ structure that are not explicitly set should
138 be initialized to 0 before the first time the structure is used. Do
139 this by declaring the structure external or static, or by calling
140 <span class="bold"><strong>memset</strong></span>(3).
141 </p>
142 <p>
143 A DB_LOCKREQ structure has at least the following fields:
144 </p>
145 <div class="itemizedlist">
146 <ul type="disc">
147 <li>
148 <p><a id="vec_op"></a>
149 <code class="literal">lockop_t op;</code>
150 </p>
151 <p>
152 The operation to be performed, which must be set to one of the
153 following values:
154 </p>
155 <div class="itemizedlist">
156 <ul type="circle">
157 <li>
158 <p><a id="vec_DB_LOCK_GET"></a>
159 <code class="literal">DB_LOCK_GET</code>
160 </p>
161 <p>
162 Get the lock defined by the values of the <span class="bold"><strong>mode</strong></span> and <span class="bold"><strong>obj</strong></span>
163 structure fields, for the specified
164 <span class="bold"><strong>locker</strong></span>.
165 Upon return from <code class="methodname">DbEnv::lock_vec()</code>,
166 if the <span class="bold"><strong>lock</strong></span> field is non-NULL, a
167 reference to the acquired lock is stored there. (This reference is
168 invalidated by any call to <code class="methodname">DbEnv::lock_vec()</code> or
169 <a class="xref" href="lockput.html" title="DbEnv::lock_put()">DbEnv::lock_put()</a> that releases
170 the lock.)
171 </p>
172 </li>
173 <li>
174 <p><a id="vec_DB_LOCK_GET_TIMEOUT"></a>
175 <code class="literal">DB_LOCK_GET_TIMEOUT</code>
176 </p>
177 <p>
178 Identical to DB_LOCK_GET except that the value in the <span class="bold"><strong>timeout</strong></span> structure field overrides any
179 previously specified timeout value for this lock. A value of 0 turns
180 off any previously specified timeout.
181 </p>
182 </li>
183 <li>
184 <p><a id="vec_DB_LOCK_PUT"></a>
185 <code class="literal">DB_LOCK_PUT</code>
186 </p>
187 <p>
188 The lock to which the <span class="bold"><strong>lock</strong></span> structure
189 field refers is released. The <span class="bold"><strong>locker</strong></span>
190 parameter, and <span class="bold"><strong>mode</strong></span> and <span class="bold"><strong>obj</strong></span> fields are ignored.
191 </p>
192 </li>
193 <li>
194 <p><a id="vec_DB_LOCK_PUT_ALL"></a>
195 <code class="literal">DB_LOCK_PUT_ALL</code>
196 </p>
197 <p>
198 All locks held by the specified <span class="bold"><strong>locker</strong></span> are released. The <span class="bold"><strong>lock</strong></span>, <span class="bold"><strong>mode</strong></span>,
199 and <span class="bold"><strong>obj</strong></span> structure fields are ignored.
200 Locks acquired in operations performed by the current call to
201 <code class="methodname">DbEnv::lock_vec()</code> which appear before the DB_LOCK_PUT_ALL operation
202 are released; those acquired in operations appearing after the
203 DB_LOCK_PUT_ALL operation are not released.
204 </p>
205 </li>
206 <li>
207 <p><a id="vec_DB_LOCK_PUT_OBJ"></a>
208 <code class="literal">DB_LOCK_PUT_OBJ</code>
209 </p>
210 <p>
211 All locks held on <span class="bold"><strong>obj</strong></span> are released.
212 The <span class="bold"><strong>locker</strong></span> parameter and the
213 <span class="bold"><strong>lock</strong></span> and <span class="bold"><strong>mode</strong></span> structure fields are ignored. Locks
214 acquired in operations performed by the current call to
215 <code class="methodname">DbEnv::lock_vec()</code> that appear before the DB_LOCK_PUT_OBJ operation
216 are released; those acquired in operations appearing after the
217 DB_LOCK_PUT_OBJ operation are not released.
218 </p>
219 </li>
220 <li>
221 <p><a id="vec_DB_LOCK_TIMEOUT"></a>
222 <code class="literal">DB_LOCK_TIMEOUT</code>
223 </p>
224 <p>
225 Cause the specified <span class="bold"><strong>locker</strong></span> to timeout
226 immediately. If the database environment has not configured automatic
227 deadlock detection, the transaction will timeout the next time
228 deadlock detection is performed. As transactions acquire locks on
229 behalf of a single locker ID, timing out the locker ID associated with
230 a transaction will time out the transaction itself.
231 </p>
232 </li>
233 </ul>
234 </div>
235 </li>
236 <li>
237 <p><a id="vec_lock"></a>
238 <code class="literal">DB_LOCK lock;</code>
239 </p>
240 <p>
241 A lock reference.
242 </p>
243 </li>
244 <li>
245 <p><a id="vec_mode"></a>
246 <code class="literal">const lockmode_t mode;</code>
247 </p>
248 <p>
249 The lock mode, used as an index into the environment's lock conflict
250 matrix. When using the default lock conflict matrix, <span class="bold"><strong>mode</strong></span> must be set to one of the following
251 values:
252 </p>
253 <div class="itemizedlist">
254 <ul type="circle">
255 <li>
256 <p><a id="vec_DB_LOCK_READ"></a>
257 <code class="literal">DB_LOCK_READ</code>
258 </p>
259 <p>
260 read (shared)
261 </p>
262 </li>
263 <li>
264 <p><a id="vec_DB_LOCK_WRITE"></a>
265 <code class="literal">DB_LOCK_WRITE</code>
266 </p>
267 <p>
268 write (exclusive)
269 </p>
270 </li>
271 <li>
272 <p><a id="vec_DB_LOCK_IWRITE"></a>
273 <code class="literal">DB_LOCK_IWRITE</code>
274 </p>
275 <p>
276 intention to write (shared)
277 </p>
278 </li>
279 <li>
280 <p><a id="vec_DB_LOCK_IREAD"></a>
281 <code class="literal">DB_LOCK_IREAD</code>
282 </p>
283 <p>
284 intention to read (shared)
285 </p>
286 </li>
287 <li>
288 <p><a id="vec_DB_LOCK_IWR"></a>
289 <code class="literal">DB_LOCK_IWR</code>
290 </p>
291 <p>
292 intention to read and write (shared)
293 </p>
294 </li>
295 </ul>
296 </div>
297 <p>
298 See <a class="xref" href="envset_lk_conflicts.html" title="DbEnv::set_lk_conflicts()">DbEnv::set_lk_conflicts()</a>
299 and <a href="../../programmer_reference/lock_stdmode.html" class="olink">Standard Lock Modes</a>
300 for more information on the lock conflict matrix.
301 </p>
302 </li>
303 <li>
304 <p>
305 <span class="bold"><a id="obj"></a><strong>const DBT obj;</strong></span>
306 </p>
307 <p>
308 An untyped byte string that specifies the object to be locked or
309 released. Applications using the locking subsystem directly while
310 also doing locking via the Berkeley DB access methods must take care
311 not to inadvertently lock objects that happen to be equal to the
312 unique file IDs used to lock files. See
313 <a href="../../programmer_reference/lock_am_conv.html" class="olink">Access method locking
314 conventions</a> in the
315 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em> for more information.
316 </p>
317 </li>
318 <li>
319 <p>
320 <span class="bold"><strong>u_int32_t timeout;</strong></span>
321 </p>
322 <p>
323 The lock timeout value.
324 </p>
325 </li>
326 </ul>
327 </div>
328 </div>
329 <div class="sect3" lang="en" xml:lang="en">
330 <div class="titlepage">
331 <div>
332 <div>
333 <h4 class="title"><a id="idp8223392"></a>nlist</h4>
334 </div>
335 </div>
336 </div>
337 <p>
338 The <span class="bold"><strong>nlist</strong></span> parameter specifies the
339 number of elements in the <span class="bold"><strong>list</strong></span> array.
340 </p>
341 </div>
342 <div class="sect3" lang="en" xml:lang="en">
343 <div class="titlepage">
344 <div>
345 <div>
346 <h4 class="title"><a id="idp8224472"></a>elistp</h4>
347 </div>
348 </div>
349 </div>
350 <p>
351 If an error occurs, and the <span class="bold"><strong>elistp</strong></span>
352 parameter is non-NULL, it is set to point to the DB_LOCKREQ entry that
353 was being processed when the error occurred.
354 </p>
355 </div>
356 </div>
357 <div class="sect2" lang="en" xml:lang="en">
358 <div class="titlepage">
359 <div>
360 <div>
361 <h3 class="title"><a id="idp8225552"></a>Errors</h3>
362 </div>
363 </div>
364 </div>
365 <p>
366 The <code class="methodname">DbEnv::lock_vec()</code> <span>
367
368 <span>
369 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
370 exception, encapsulating one of the following non-zero errors, or return one
371 of the following non-zero errors:
372 </span>
373 </span>
374 </p>
375 <div class="sect3" lang="en" xml:lang="en">
376 <div class="titlepage">
377 <div>
378 <div>
379 <h4 class="title"><a id="idp8193312"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
380 </div>
381 </div>
382 </div>
383 <p>
384 A transactional database environment operation was selected to resolve
385 a deadlock.
386 </p>
387 <p>
388 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
389 your Berkeley DB API is configured to throw exceptions.
390 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
391 </p>
392 </div>
393 <div class="sect3" lang="en" xml:lang="en">
394 <div class="titlepage">
395 <div>
396 <div>
397 <h4 class="title"><a id="idp8205440"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
398 </div>
399 </div>
400 </div>
401 <p>
402 A Berkeley DB Concurrent Data Store database environment configured
403 for lock timeouts was unable to grant a lock in the allowed time.
404 </p>
405 <p>
406 You attempted to open a database handle that is configured
407 for no waiting exclusive locking, but the exclusive lock could not be
408 immediately obtained. See
409 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
410 for more information.
411 </p>
412 <p>
413 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
414 your Berkeley DB API is configured to throw exceptions.
415 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
416 </p>
417 </div>
418 <div class="sect3" lang="en" xml:lang="en">
419 <div class="titlepage">
420 <div>
421 <div>
422 <h4 class="title"><a id="idp8173592"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
423 </div>
424 </div>
425 </div>
426 <p>
427 The <a class="link" href="lockvec.html#vec_DB_LOCK_NOWAIT">DB_LOCK_NOWAIT</a>
428 flag or lock timers were configured and the lock could not be granted
429 before the wait-time expired.
430 </p>
431 <p>
432 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
433 your Berkeley DB API is configured to throw exceptions.
434 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
435 </p>
436 </div>
437 <div class="sect3" lang="en" xml:lang="en">
438 <div class="titlepage">
439 <div>
440 <div>
441 <h4 class="title"><a id="idp8158096"></a>EINVAL</h4>
442 </div>
443 </div>
444 </div>
445 <p>
446 An invalid flag value or parameter was specified.
447 </p>
448 </div>
449 <div class="sect3" lang="en" xml:lang="en">
450 <div class="titlepage">
451 <div>
452 <div>
453 <h4 class="title"><a id="idp8158536"></a>ENOMEM</h4>
454 </div>
455 </div>
456 </div>
457 <p>
458 The maximum number of locks has been reached.
459 </p>
460 </div>
461 </div>
462 <div class="sect2" lang="en" xml:lang="en">
463 <div class="titlepage">
464 <div>
465 <div>
466 <h3 class="title"><a id="idp8195856"></a>Class</h3>
467 </div>
468 </div>
469 </div>
470 <p>
471 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>,
472 <a class="link" href="lock.html" title="Chapter 7.  The DbLock Handle">DbLock</a>
473 </p>
474 </div>
475 <div class="sect2" lang="en" xml:lang="en">
476 <div class="titlepage">
477 <div>
478 <div>
479 <h3 class="title"><a id="idp8226528"></a>See Also</h3>
480 </div>
481 </div>
482 </div>
483 <p>
484 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a>
485 </p>
486 </div>
487 </div>
488 <div class="navfooter">
489 <hr />
490 <table width="100%" summary="Navigation footer">
491 <tr>
492 <td width="40%" align="left"><a accesskey="p" href="lockstat_print.html">Prev</a> </td>
493 <td width="20%" align="center">
494 <a accesskey="u" href="lock.html">Up</a>
495 </td>
496 <td width="40%" align="right"> <a accesskey="n" href="lsn.html">Next</a></td>
497 </tr>
498 <tr>
499 <td width="40%" align="left" valign="top">DbEnv::lock_stat_print() </td>
500 <td width="20%" align="center">
501 <a accesskey="h" href="index.html">Home</a>
502 </td>
503 <td width="40%" align="right" valign="top"> Chapter 8. 
504 The DbLsn Handle
505 </td>
506 </tr>
507 </table>
508 </div>
509 </body>
510 </html>