File: ACE_File_Lock.3

package info (click to toggle)
ace 5.2.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 26,856 kB
  • ctags: 18,677
  • sloc: cpp: 171,831; makefile: 48,840; sh: 10,192; perl: 8,582; exp: 787; yacc: 387; lex: 140; csh: 20
file content (198 lines) | stat: -rw-r--r-- 8,195 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
.TH ACE_File_Lock 3 "1 Dec 2001" "ACE" \" -*- nroff -*-
.ad l
.nh
.SH NAME
ACE_File_Lock \- A wrapper around the UNIX file locking mechanism. 
.SH SYNOPSIS
.br
.PP
\fC#include <File_Lock.h>\fR
.PP
.SS Public Methods

.in +1c
.ti -1c
.RI "\fBACE_File_Lock\fR (ACE_HANDLE handle = ACE_INVALID_HANDLE, int unlink_in_destructor = 1)"
.br
.ti -1c
.RI "\fBACE_File_Lock\fR (const \fBACE_TCHAR\fR *filename, int flags, \fBmode_t\fR mode = 0, int unlink_in_destructor = 1)"
.br
.RI "\fIOpen the <filename> with <flags> and <mode> and set the result to <handle_>. If you don't want the file unlinked in the destructor pass a zero value for <unlink_in_destructor>.\fR"
.ti -1c
.RI "int \fBopen\fR (const \fBACE_TCHAR\fR *filename, int flags, \fBmode_t\fR mode = 0)"
.br
.RI "\fIOpen the <filename> with <flags> and <mode> and set the result to <handle_>.\fR"
.ti -1c
.RI "\fB~ACE_File_Lock\fR (void)"
.br
.RI "\fIRemove a File lock by releasing it and closing down the <handle_>.\fR"
.ti -1c
.RI "int \fBremove\fR (int unlink_file = 1)"
.br
.RI "\fIRemove a File lock by releasing it and closing down the <handle_>. If <unlink_file> is non-0 then we unlink the file.\fR"
.ti -1c
.RI "int \fBacquire\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "int \fBtryacquire\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "int \fBrelease\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.RI "\fIUnlock a readers/writer lock.\fR"
.ti -1c
.RI "int \fBacquire_write\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.RI "\fIAcquire a write lock, but block if any readers or a writer hold the lock.\fR"
.ti -1c
.RI "int \fBtryacquire_write\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "int \fBtryacquire_write_upgrade\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "int \fBacquire_read\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "int \fBtryacquire_read\fR (short whence = 0, off_t start = 0, off_t len = 1)"
.br
.ti -1c
.RI "ACE_HANDLE \fBget_handle\fR (void) const"
.br
.RI "\fIGet underlying  for the file.\fR"
.ti -1c
.RI "void \fBset_handle\fR (ACE_HANDLE)"
.br
.ti -1c
.RI "void \fBdump\fR (void) const"
.br
.RI "\fIDump state of the object.\fR"
.in -1c
.SS Public Attributes

.in +1c
.ti -1c
.RI "\fBACE_ALLOC_HOOK_DECLARE\fR"
.br
.RI "\fIDeclare the dynamic allocation hooks.\fR"
.in -1c
.SS Protected Attributes

.in +1c
.ti -1c
.RI "\fBACE_OS::ace_flock_t\fR \fBlock_\fR"
.br
.RI "\fILocking structure for OS record locks.\fR"
.ti -1c
.RI "int \fBremoved_\fR"
.br
.RI "\fIKeeps track of whether <remove> has been called yet to avoid multiple <remove> calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling <remove> on the same object, which is a bad idea anyway...\fR"
.ti -1c
.RI "int \fBunlink_in_destructor_\fR"
.br
.RI "\fIKeeps track of whether to unlink the underlying file in the destructor.\fR"
.in -1c
.SS Private Methods

.in +1c
.ti -1c
.RI "void \fBoperator=\fR (const ACE_File_Lock &)"
.br
.ti -1c
.RI "\fBACE_File_Lock\fR (const ACE_File_Lock &)"
.br
.in -1c
.SH DETAILED DESCRIPTION
.PP 
A wrapper around the UNIX file locking mechanism.
.PP
.PP
 Allows us to "adapt" the UNIX file locking mechanisms to work with all of our Guard stuff... 
.PP
.SH CONSTRUCTOR & DESTRUCTOR DOCUMENTATION
.PP 
.SS ACE_File_Lock::ACE_File_Lock (ACE_HANDLE handle = ACE_INVALID_HANDLE, int unlink_in_destructor = 1)
.PP
Set the <handle_> of the File_Lock to <handle>. Note that this constructor assumes ownership of the <handle> and will close it down in <remove>. If you want the <handle> to stay open when <remove> is called make sure to call <dup> on the <handle>. If you don't want the file unlinked in the destructor pass a zero value for <unlink_in_destructor>. 
.SS ACE_File_Lock::ACE_File_Lock (const \fBACE_TCHAR\fR * filename, int flags, \fBmode_t\fR mode = 0, int unlink_in_destructor = 1)
.PP
Open the <filename> with <flags> and <mode> and set the result to <handle_>. If you don't want the file unlinked in the destructor pass a zero value for <unlink_in_destructor>.
.PP
.SS ACE_File_Lock::~ACE_File_Lock (void)
.PP
Remove a File lock by releasing it and closing down the <handle_>.
.PP
.SS ACE_File_Lock::ACE_File_Lock (const ACE_File_Lock &)\fC [private]\fR
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.PP 
.SS int ACE_File_Lock::acquire (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Note, for interface uniformity with other synchronization wrappers we include the  method. This is implemented as a write-lock to be on the safe-side... 
.SS int ACE_File_Lock::acquire_read (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Acquire a read lock, but block if a writer hold the lock. Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_File_Lock::acquire_write (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Acquire a write lock, but block if any readers or a writer hold the lock.
.PP
.SS void ACE_File_Lock::dump (void) const
.PP
Dump state of the object.
.PP
.SS ACE_HANDLE ACE_File_Lock::get_handle (void) const
.PP
Get underlying  for the file.
.PP
.SS int ACE_File_Lock::open (const \fBACE_TCHAR\fR * filename, int flags, \fBmode_t\fR mode = 0)
.PP
Open the <filename> with <flags> and <mode> and set the result to <handle_>.
.PP
.SS void ACE_File_Lock::operator= (const ACE_File_Lock &)\fC [private]\fR
.PP
.SS int ACE_File_Lock::release (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Unlock a readers/writer lock.
.PP
.SS int ACE_File_Lock::remove (int unlink_file = 1)
.PP
Remove a File lock by releasing it and closing down the <handle_>. If <unlink_file> is non-0 then we unlink the file.
.PP
.SS void ACE_File_Lock::set_handle (ACE_HANDLE)
.PP
Set underlying . Note that this method assumes ownership of the <handle> and will close it down in <remove>. If you want the <handle> to stay open when <remove> is called make sure to call <dup> on the <handle> before closing it. You are responsible for the closing the existing <handle> before overwriting it. 
.SS int ACE_File_Lock::tryacquire (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Note, for interface uniformity with other synchronization wrappers we include the <tryacquire> method. This is implemented as a write-lock to be on the safe-side... Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_File_Lock::tryacquire_read (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Conditionally acquire a read lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_File_Lock::tryacquire_write (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Conditionally acquire a write lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_File_Lock::tryacquire_write_upgrade (short whence = 0, off_t start = 0, off_t len = 1)
.PP
Conditionally upgrade to a write lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SH MEMBER DATA DOCUMENTATION
.PP 
.SS ACE_File_Lock::ACE_ALLOC_HOOK_DECLARE
.PP
Declare the dynamic allocation hooks.
.PP
.SS \fBACE_OS::ace_flock_t\fR ACE_File_Lock::lock_\fC [protected]\fR
.PP
Locking structure for OS record locks.
.PP
.SS int ACE_File_Lock::removed_\fC [protected]\fR
.PP
Keeps track of whether <remove> has been called yet to avoid multiple <remove> calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling <remove> on the same object, which is a bad idea anyway...
.PP
.SS int ACE_File_Lock::unlink_in_destructor_\fC [protected]\fR
.PP
Keeps track of whether to unlink the underlying file in the destructor.
.PP


.SH AUTHOR
.PP 
Generated automatically by Doxygen for ACE from the source code.