File: TelEngine__Semaphore.html

package info (click to toggle)
yate 2.2.0-1~dfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 17,496 kB
  • ctags: 21,687
  • sloc: cpp: 126,248; ansic: 11,462; sh: 3,573; php: 3,229; python: 2,014; makefile: 1,504; perl: 465; awk: 8
file content (133 lines) | stat: -rw-r--r-- 7,312 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
<HTML>
<HEAD>
<TITLE>class Semaphore</TITLE>

<META NAME="Generator" CONTENT="KDOC ">
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD>
	<TABLE BORDER="0">
		<TR><TD valign="top" align="left" cellspacing="10">
		<h1>class Semaphore</h1>
		</TD>
		<TD valign="top" align="right" colspan="1">Semaphore implementation. <small><A HREF="#longdesc">More...</A></small></TD></TR>
	</TABLE>
	<HR>
	<TABLE BORDER="0">
		<TR><TH>Full name</TH><TD><code><A HREF="TelEngine.html">TelEngine</A>::Semaphore</code></TD></TR>
<TR><TH>Definition</TH><TD><code>#include &lt;<A HREF="yateclass_h.html">yateclass.h</A>&gt;</code></TD></TR>
<TR><TH>Inherits</TH><TD><i><A HREF="TelEngine__Lockable.html">TelEngine::Lockable</A></i> <small>[public ]</small></TD></TR>
<TR><TH><A HREF="full-list-TelEngine__Semaphore.html">List of all Methods</A></TH></TR>
	</TABLE>
	</TD>
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
</TABLE></TD></TR></TABLE>
<h4>Public Methods</h4><ul><LI>&nbsp;<b><A HREF="#ref2">Semaphore</A></b> (unsigned int maxcount = 1, const char* name = 0) 
</LI>
<LI>&nbsp;<b><A HREF="#ref3">Semaphore</A></b> (const Semaphore& original) 
</LI>
<LI>&nbsp;<b><A HREF="#ref4">~Semaphore</A></b> () 
</LI>
<LI>Semaphore& &nbsp;<b><A HREF="#ref5">operator=</A></b> (const Semaphore& original) 
</LI>
<LI>virtual  bool &nbsp;<b><A HREF="#ref6">lock</A></b> (long maxwait = -1) 
</LI>
<LI>virtual  bool &nbsp;<b><A HREF="#ref7">unlock</A></b> () 
</LI>
<LI>virtual  bool &nbsp;<b><A HREF="#ref8">locked</A></b> ()  const
</LI>
</ul><h4>Public Static Methods</h4><ul><LI>static  int &nbsp;<b><A HREF="#ref9">count</A></b> () 
</LI>
<LI>static  int &nbsp;<b><A HREF="#ref10">locks</A></b> () 
</LI>
<LI>static  bool &nbsp;<b><A HREF="#ref11">efficientTimedLock</A></b> () 
</LI>
</ul><HR><H2><A NAME="longdesc">Detailed Description</A></H2><p>
 A semaphore object for synchronizing threads, can also be used as a token bucket
</p>
<A NAME="Semaphore"></A><A NAME="ref2"></A><table width="100%"><tr bgcolor="#eeeeee"><td>&nbsp;<strong>Semaphore</strong> (unsigned int maxcount = 1, const char* name = 0)
<br></td><td align="right"><h3><strong>Semaphore</strong></h3></td></tr></table><p></p><p>
 Construct a new unlocked semaphore
</p>
<p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>maxcount</i></TD><TD align="left" valign="top">Maximum unlock count, must be strictly positive
</TD></TR>
<TR><TD align="left" valign="top"><i>name</i></TD><TD align="left" valign="top">Static name of the semaphore (for debugging purpose only)
     </TD></TR>
</TABLE></P>
<A NAME="Semaphore"></A><A NAME="ref3"></A><table width="100%"><tr bgcolor="#eeeeee"><td>&nbsp;<strong>Semaphore</strong> (const Semaphore& original)
<br></td><td align="right"><h3><strong>Semaphore</strong></h3></td></tr></table><p></p><p>
 Copy constructor, creates a shared semaphore
</p>
<p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>original</i></TD><TD align="left" valign="top">Reference of the semaphore to share
     </TD></TR>
</TABLE></P>
<A NAME="~Semaphore"></A><A NAME="ref4"></A><table width="100%"><tr bgcolor="#eeeeee"><td>&nbsp;<strong>~Semaphore</strong> ()
<br></td><td align="right"><h3><strong>~Semaphore</strong></h3></td></tr></table><p></p><p>
 Destroy the semaphore
     </p>
<A NAME="operator="></A><A NAME="ref5"></A><table width="100%"><tr bgcolor="#eeeeee"><td>Semaphore& &nbsp;<strong>operator=</strong> (const Semaphore& original)
<br></td><td align="right"><h3><strong>operator=</strong></h3></td></tr></table><p></p><p>
 Assignment operator makes the semaphore shared with the original
</p>
<p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>original</i></TD><TD align="left" valign="top">Reference of the semaphore to share
     </TD></TR>
</TABLE></P>
<A NAME="lock"></A><A NAME="ref6"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool &nbsp;<strong>lock</strong> (long maxwait = -1)
<br></td><td align="right"><h3><strong>lock</strong></h3></td></tr></table><p> <small>[virtual]</small></p><p>
 Attempt to get a lock on the semaphore and eventually wait for it
</p>
<p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>maxwait</i></TD><TD align="left" valign="top">Time in microseconds to wait, -1 wait forever
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: True if successfully locked, false on failure
     </p>
<p>Reimplemented from <A HREF="TelEngine__Lockable.html#lock">Lockable</A>.</p>
<A NAME="unlock"></A><A NAME="ref7"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool &nbsp;<strong>unlock</strong> ()
<br></td><td align="right"><h3><strong>unlock</strong></h3></td></tr></table><p> <small>[virtual]</small></p><p>
 Unlock the semaphore, does never wait nor get over counter maximum
</p>
<p><b>Returns</b>: True if successfully unlocked
     </p>
<p>Reimplemented from <A HREF="TelEngine__Lockable.html#unlock">Lockable</A>.</p>
<A NAME="locked"></A><A NAME="ref8"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool &nbsp;<strong>locked</strong> ()
<br></td><td align="right"><h3><strong>locked</strong></h3></td></tr></table><p> <small>[const virtual]</small></p><p>
 Check if the semaphore is currently locked (waiting) - as it's
  asynchronous it guarantees nothing if other thread changes status
</p>
<p><b>Returns</b>: True if the semaphore was locked when the function was called
     </p>
<p>Reimplemented from <A HREF="TelEngine__Lockable.html#locked">Lockable</A>.</p>
<A NAME="count"></A><A NAME="ref9"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int &nbsp;<strong>count</strong> ()
<br></td><td align="right"><h3><strong>count</strong></h3></td></tr></table><p> <small>[static]</small></p><p>
 Get the number of semaphores counting the shared ones only once
</p>
<p><b>Returns</b>: Count of individual semaphores
     </p>
<A NAME="locks"></A><A NAME="ref10"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int &nbsp;<strong>locks</strong> ()
<br></td><td align="right"><h3><strong>locks</strong></h3></td></tr></table><p> <small>[static]</small></p><p>
 Get the number of currently locked (waiting) semaphores
</p>
<p><b>Returns</b>: Count of locked semaphores, should be zero at program exit
     </p>
<A NAME="efficientTimedLock"></A><A NAME="ref11"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool &nbsp;<strong>efficientTimedLock</strong> ()
<br></td><td align="right"><h3><strong>efficientTimedLock</strong></h3></td></tr></table><p> <small>[static]</small></p><p>
 Check if a timed lock() is efficient on this platform
</p>
<p><b>Returns</b>: True if a lock with a maxwait parameter is efficiently implemented
     </p>
<HR>
	<table>
	<tr><td><small>Generated by: paulc on bussard on Mon Mar  8 12:18:15 2010, using kdoc 2.0a54.</small></td></tr>
	</table>
</BODY>
</HTML>