Debian Codegraph @

docs/programmer_reference/lock_nondb.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>Locking and non-Berkeley DB applications</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="lock.html" title="Chapter 16.  The Locking Subsystem" />
11 <link rel="prev" href="lock_am_conv.html" title="Berkeley DB Transactional Data Store locking conventions" />
12 <link rel="next" href="log.html" title="Chapter 17.  The Logging Subsystem" />
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">Locking and non-Berkeley DB applications</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="lock_am_conv.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 16. 
26 The Locking Subsystem
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="log.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="lock_nondb"></a>Locking and non-Berkeley DB applications</h2>
38 </div>
39 </div>
40 </div>
41 <p>The Lock subsystem is useful outside the context of Berkeley DB. It can be
42 used to manage concurrent access to any collection of either ephemeral
43 or persistent objects. That is, the lock region can persist across
44 invocations of an application, so it can be used to provide long-term
45 locking (for example, conference room scheduling).</p>
46 <p>In order to use the locking subsystem in such a general way, the
47 applications must adhere to a convention for identifying objects and
48 lockers. Consider a conference room scheduling problem, in which there
49 are three conference rooms scheduled in half-hour intervals. The
50 scheduling application must then select a way to identify each
51 conference room/time slot combination. In this case, we could describe
52 the objects being locked as bytestrings consisting of the conference
53 room name, the date when it is needed, and the beginning of the
54 appropriate half-hour slot.</p>
55 <p>Lockers are 32-bit numbers, so we might choose to use the User ID of
56 the individual running the scheduling program. To schedule half-hour
57 slots, all the application needs to do is issue a <a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> call
58 for the appropriate locker/object pair. To schedule a longer slot, the
59 application needs to issue a <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call, with one
60 <a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> operation per half-hour — up to the total length. If
61 the <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call fails, the application would have to release
62 the parts of the time slot that were obtained.</p>
63 <p>To cancel a reservation, the application would make the appropriate
64 <a href="../api_reference/C/lockput.html" class="olink">DB_ENV-&gt;lock_put()</a> calls. To reschedule a reservation, the
65 <a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> and <a href="../api_reference/C/lockput.html" class="olink">DB_ENV-&gt;lock_put()</a> calls could all be made inside of
66 a single <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call. The output of <a href="../api_reference/C/lockstat.html" class="olink">DB_ENV-&gt;lock_stat()</a> could
67 be post-processed into a human-readable schedule of conference room
68 use.</p>
69 </div>
70 <div class="navfooter">
71 <hr />
72 <table width="100%" summary="Navigation footer">
73 <tr>
74 <td width="40%" align="left"><a accesskey="p" href="lock_am_conv.html">Prev</a> </td>
75 <td width="20%" align="center">
76 <a accesskey="u" href="lock.html">Up</a>
77 </td>
78 <td width="40%" align="right"> <a accesskey="n" href="log.html">Next</a></td>
79 </tr>
80 <tr>
81 <td width="40%" align="left" valign="top">Berkeley DB Transactional Data Store locking conventions </td>
82 <td width="20%" align="center">
83 <a accesskey="h" href="index.html">Home</a>
84 </td>
85 <td width="40%" align="right" valign="top"> Chapter 17. 
86 The Logging Subsystem
87 </td>
88 </tr>
89 </table>
90 </div>
91 </body>
92 </html>