File: ACE_Semaphore.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 (190 lines) | stat: -rw-r--r-- 7,476 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
.TH ACE_Semaphore 3 "1 Dec 2001" "ACE" \" -*- nroff -*-
.ad l
.nh
.SH NAME
ACE_Semaphore \- Wrapper for Dijkstra style general semaphores. 
.SH SYNOPSIS
.br
.PP
\fC#include <Synch.h>\fR
.PP
Inherited by \fBACE_Thread_Semaphore\fR.
.PP
.SS Public Methods

.in +1c
.ti -1c
.RI "\fBACE_Semaphore\fR (u_int count = 1, int type = USYNC_THREAD, const \fBACE_TCHAR\fR *name = 0, void * = 0, int max = 0x7fffffff)"
.br
.RI "\fIInitialize the semaphore, with initial value of "count".\fR"
.ti -1c
.RI "\fB~ACE_Semaphore\fR (void)"
.br
.RI "\fIImplicitly destroy the semaphore.\fR"
.ti -1c
.RI "int \fBremove\fR (void)"
.br
.ti -1c
.RI "int \fBacquire\fR (void)"
.br
.RI "\fIBlock the thread until the semaphore count becomes greater than 0, then decrement it.\fR"
.ti -1c
.RI "int \fBacquire\fR (\fBACE_Time_Value\fR &tv)"
.br
.ti -1c
.RI "int \fBacquire\fR (\fBACE_Time_Value\fR *tv)"
.br
.ti -1c
.RI "int \fBtryacquire\fR (void)"
.br
.ti -1c
.RI "int \fBrelease\fR (void)"
.br
.RI "\fIIncrement the semaphore by 1, potentially unblocking a waiting thread.\fR"
.ti -1c
.RI "int \fBrelease\fR (size_t release_count)"
.br
.RI "\fIIncrement the semaphore by <release_count>, potentially unblocking waiting threads.\fR"
.ti -1c
.RI "int \fBacquire_read\fR (void)"
.br
.ti -1c
.RI "int \fBacquire_write\fR (void)"
.br
.ti -1c
.RI "int \fBtryacquire_read\fR (void)"
.br
.ti -1c
.RI "int \fBtryacquire_write\fR (void)"
.br
.ti -1c
.RI "int \fBtryacquire_write_upgrade\fR (void)"
.br
.ti -1c
.RI "void \fBdump\fR (void) const"
.br
.RI "\fIDump the state of an object.\fR"
.ti -1c
.RI "const ACE_sema_t& \fBlock\fR (void) const"
.br
.RI "\fIReturn the underlying lock.\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 "ACE_sema_t \fBsemaphore_\fR"
.br
.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"
.in -1c
.SS Private Methods

.in +1c
.ti -1c
.RI "void \fBoperator=\fR (const ACE_Semaphore &)"
.br
.ti -1c
.RI "\fBACE_Semaphore\fR (const ACE_Semaphore &)"
.br
.in -1c
.SH DETAILED DESCRIPTION
.PP 
Wrapper for Dijkstra style general semaphores.
.PP
.SH CONSTRUCTOR & DESTRUCTOR DOCUMENTATION
.PP 
.SS ACE_Semaphore::ACE_Semaphore (u_int count = 1, int type = USYNC_THREAD, const \fBACE_TCHAR\fR * name = 0, void * = 0, int max = 0x7fffffff)
.PP
Initialize the semaphore, with initial value of "count".
.PP
.SS ACE_Semaphore::~ACE_Semaphore (void)
.PP
Implicitly destroy the semaphore.
.PP
.SS ACE_Semaphore::ACE_Semaphore (const ACE_Semaphore &)\fC [private]\fR
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.PP 
.SS int ACE_Semaphore::acquire (\fBACE_Time_Value\fR * tv)
.PP
If <tv> == 0 then call  directly. Otherwise, Block the thread until the semaphore count becomes greater than 0  (at which point it is decremented) or until <tv> times out (in which case -1 is returned and <errno> == <ETIME>). Note that <*tv> is assumed to be in "absolute" rather than "relative" time. The value of <*tv> is updated upon return to show the actual (absolute) acquisition time.
.PP
NOTE: Solaris threads do not support timed semaphores. Therefore, if you're running on Solaris you might want to consider using the \fBACE\fR POSIX pthreads implementation instead, which can be enabled by compiling \fBACE\fR with -DACE_HAS_PTHREADS, rather than -DACE_HAS_STHREADS or  -DACE_HAS_POSIX_SEM. 
.SS int ACE_Semaphore::acquire (\fBACE_Time_Value\fR & tv)
.PP
Block the thread until the semaphore count becomes greater than 0 (at which point it is decremented) or until <tv> times out (in which case -1 is returned and <errno> == <ETIME>). Note that <tv> is assumed to be in "absolute" rather than "relative" time. The value of <tv> is updated upon return to show the actual (absolute) acquisition time.
.PP
NOTE: Solaris threads do not support timed semaphores. Therefore, if you're running on Solaris you might want to consider using the \fBACE\fR POSIX pthreads implementation instead, which can be enabled by compiling \fBACE\fR with -DACE_HAS_PTHREADS, rather than -DACE_HAS_STHREADS or -DACE_HAS_POSIX_SEM. 
.SS int ACE_Semaphore::acquire (void)
.PP
Block the thread until the semaphore count becomes greater than 0, then decrement it.
.PP
.SS int ACE_Semaphore::acquire_read (void)
.PP
Acquire semaphore ownership. This calls  and is only here to make the  interface consistent with the other synchronization APIs. 
.SS int ACE_Semaphore::acquire_write (void)
.PP
Acquire semaphore ownership. This calls  and is only here to make the  interface consistent with the other synchronization APIs. 
.SS void ACE_Semaphore::dump (void) const
.PP
Dump the state of an object.
.PP
Reimplemented in \fBACE_Thread_Semaphore\fR.
.SS const ACE_sema_t & ACE_Semaphore::lock (void) const
.PP
Return the underlying lock.
.PP
.SS void ACE_Semaphore::operator= (const ACE_Semaphore &)\fC [private]\fR
.PP
.SS int ACE_Semaphore::release (size_t release_count)
.PP
Increment the semaphore by <release_count>, potentially unblocking waiting threads.
.PP
.SS int ACE_Semaphore::release (void)
.PP
Increment the semaphore by 1, potentially unblocking a waiting thread.
.PP
.SS int ACE_Semaphore::remove (void)
.PP
Explicitly destroy the semaphore. Note that only one thread should call this method since it doesn't protect against race conditions. 
.SS int ACE_Semaphore::tryacquire (void)
.PP
Conditionally decrement the semaphore if count is greater than 0 (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_Semaphore::tryacquire_read (void)
.PP
Conditionally acquire semaphore (i.e., won't block). This calls <tryacquire> and is only here to make the  interface consistent with the other synchronization APIs. Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_Semaphore::tryacquire_write (void)
.PP
Conditionally acquire semaphore (i.e., won't block). This calls <tryacquire> and is only here to make the  interface consistent with the other synchronization APIs. Returns -1 on failure. If we "failed" because someone else already had the lock, <errno> is set to <EBUSY>. 
.SS int ACE_Semaphore::tryacquire_write_upgrade (void)
.PP
This is only here to make the  interface consistent with the other synchronization APIs. Assumes the caller has already acquired the semaphore using one of the above calls, and returns 0 (success) always. 
.SH MEMBER DATA DOCUMENTATION
.PP 
.SS ACE_Semaphore::ACE_ALLOC_HOOK_DECLARE
.PP
Declare the dynamic allocation hooks.
.PP
Reimplemented in \fBACE_Thread_Semaphore\fR.
.SS int ACE_Semaphore::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 ACE_sema_t ACE_Semaphore::semaphore_\fC [protected]\fR
.PP


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