vfs: check userland buffers before reading them.
[haiku.git] / docs / develop / support / usecases / BAutolockUseCases.html
blobf4961b2ac219bd2192b8ee6ee2adba96ad0a7f8a
1 <HTML>
2 <!-- $Id: BAutolockUseCases.html 10 2002-07-09 12:24:59Z ejakowatz $ -->
3 <HEAD>
4 <TITLE>BAutolock Use Cases and Implementation Details</TITLE>
5 </HEAD>
7 <BODY BGCOLOR="white" LINK="#000067" VLINK="#000067" ALINK="#0000FF">
9 <FONT FACE="Verdana,Arial,Helvetica,sans-serif" SIZE="-1">
11 <H1>BAutolock Use Cases and Implementation Details:</H1>
13 <P>This document describes the BAutolock interface and some basics of how it is implemented.
14 The document has the following sections:</P>
16 <OL>
17 <LI><A HREF="#interface">BAutolock Interface</A></LI>
18 <LI><A HREF="#usecases">BAutolock Use Cases</A></LI>
19 <LI><A HREF="#implement">BAutolock Implementation</A></LI>
20 </OL>
22 <A NAME="interface"></A><H2>BAutolock Interface:</H2>
24 <P>The BAutolock class is a simple class for handling synchronization between threads. The best
25 source of information for the BAutolock interface can be found
26 <A HREF="file:///boot/beos/documentation/Be%20Book/The%20Support%20Kit/Autolock.html">here in the Be Book</A>.
27 </P>
29 <A NAME="usecases"></A><H2>BAutolock Use Cases:</H2>
31 <P>The following use cases cover the BAutolock functionality:</P>
33 <OL>
34 <LI><P><B>Construction 1:</B> A BAutolock can be created by passing a pointer to a BLocker object.
35 An attempt will be made to Lock() this BLocker during the construction of the BAutolock object.
36 </P></LI>
38 <LI><P><B>Construction 2:</B> A BAutolock can be created by passing a reference to a BLocker object.
39 An attempt will be made to Lock() this BLocker during the construction of the BAutolock object.
40 </P></LI>
42 <LI><P><B>Construction 3:</B> A BAutolock can be created by passing a pointer to a BLooper object.
43 An attempt will be made to Lock() this BLooper during the construction of the BAutolock object.
44 </P></LI>
46 <LI><P><B>Is Locked:</B> When the BAutolock is constructed, a lock is attempted on the BLocker or
47 BLooper passed in. The result of that lock attempt is returned by calling IsLocked() on the
48 BAutolock. The result is a boolean. True is returned if the lock was successfully acquired.
49 False is returned if the lock could not be acquired. See the docs for BLocker and BLooper to
50 find out why the lock acquisition may fail.</P></LI>
52 <LI><P><B>Destruction 1:</B> If the lock acquisition on the BLocker or BLooper was successful at
53 construction time, when the BAutolock is destructed, the lock will be released by calling Unlock()
54 on the BLocker or BLooper.</P></LI>
56 <LI><P><B>Destruction 2:</B> If the lock acquisition on the BLocker or BLooper failed at
57 construction time, when the BAutolock is destructed, nothing is done to the BLocker or the BLooper.
58 An Unlock() is not attempted because the lock at construction time failed.</P></LI>
60 </OL>
62 <A NAME="implement"></A><H2>BAutolock Implementation:</H2>
64 <P>The entire BAutolock implementation is inline. Because BAutolock is implemented inline, there
65 is no code for BAutolock in libbe.so. The code is all in Be's Autolock.h header file and compiled
66 at build time directly into any object being built.</P>
68 <P>This has some interesting implications from a backwards compatibility perspective. Because
69 there are no references from existing non-Be executables and libraries to libbe.so expecting
70 to find the BAutolock class, the entire definition of BAutolock can be changed almost without risk
71 of breaking compatibility. This gives anyone wishing to expand and build on the current BAutolock
72 class a great deal of flexibility.</P>
74 <P>However, it may be worthwhile when changing BAutolock in the future to try and stay source
75 compatible. That way, existing source code will continue to compile without having to update
76 it.</P>
78 </BODY>
79 </HTML>