⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 semaphore.html

📁 多线程库
💻 HTML
字号:
<HTML><HEAD><TITLE>semaphore Class</TITLE></HEAD><BODY bgcolor="#ffffff"><H1>semaphore Class Reference</H1><p>[<A HREF="index.html">threads Index</A>] [<A HREF="heir.html">threads Hierarchy</A>]</p><HR><P>Implements a semaphore, for thread synchronisation.   <a href="#short">More...</a></P><P><code>	#include &lt;<a href="-usr-local-include-thread_semaphore-h.html">/usr/local/include/thread_semaphore.h</a>&gt;</code></P><H2>Public Members</H2><UL><LI><b><a name="ref0">semaphore</a></b> (attributes::scope) </LI><LI><b><a name="ref1">semaphore</a></b> (attributes::scope, int) </LI><LI><b><a name="ref2">semaphore</a></b> () </LI><LI><b><a name="ref3">semaphore</a></b> (int) </LI><LI><b><a name="ref4">~semaphore</a></b> () </LI><LI>int <b><a href="#ref5">post</a></b> () </LI><LI>int <b><a href="#ref6">wait</a></b> () </LI><LI>int <b><a href="#ref7">trywait</a></b> () </LI><LI>static void <b><a href="#ref8">project_part</a></b> (const char *) </LI></UL><H2>Protected Members</H2><UL><LI>  static char *<b><a name="ref9">s_project</a></b></LI><LI>  int <b><a name="ref10">s_id</a></b></LI><LI>  wait_queue *<b><a name="ref11">s_waiting</a></b></LI><LI>  attributes::scope <b><a name="ref12">s_scope</a></b></LI><LI>    int <b><a name="ref13">s_magic</a></b></LI><LI>    spinlock <b><a name="ref14">s_sync</a></b></LI><LI>    int <b><a name="ref15">s_count</a></b></LI></UL><HR><H2><a name="short">Detailed Description</a></H2><P> A semaphore, it functions in much a similar way as a mutex does, but with some exceptions.</p><p></P><HR><H2>int <a name="ref5"></a><a name="post">post</a>()  </H2><p> Increment the semaphore count, the top most blocking thread on the waiting list is restarted.</p><p></p><dl><dt><b>Returns</b>:<dd>The updated value, of the semaphore count.</dl><H2>int <a name="ref6"></a><a name="wait">wait</a>()  </H2><p> Block the calling process, until the semaphore count becomes greater than 1, then atomically decrement it. </p><dl><dt><b>Returns</b>:<dd>The current count of the semaphore.</dl><H2>int <a name="ref7"></a><a name="trywait">trywait</a>()  </H2><p> Decrement the count, if it is greater than zero.  This is a non-blocking call.</p><p></p><dl><dt><b>Returns</b>:<dd>The count of the semaphore after decrement, or -1 not.</dl><H2>static void <a name="ref8"></a><a name="project_part">project_part</a>(const char *)  </H2><p> The shared memory scheme, wants a single name to identify the overall program.  It is possible, and perhaps desired that part cond/mutex/semaphore have their own name identification tree.  This is possible, by stating that it should be branch of the main file name, with a give extension.</p><p> <pre> main() {   semaphore *sv;</p><p>   pthread::set_project( "my_project" );   semaphore::project_par( "sem" );   sv = new semaphore(attributes::process_shared);   ... } </pre></p><p> This will set the project to my_project, and all semaphores will be derived from my_project_sem.</p><p></p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">part</td><td align="left" valign="top">A C string containing the semaphore part name.</td></tr></table></dl><HR><TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top"><UL><LI><I>Author</I>: Orn E. Hansen &lt;oe.hansen@gamma.telenordia.se&gt; </LI><LI>Documentation generated by oehansen@citadel on Mi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -