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

📄 pthread.html

📁 多线程库
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<H2>bool <a name="ref16"></a><a name="detached">detached</a>()  </H2><p> Usually all threads created by the main program will be hanging on to it.  This means, that when the main program stops execution, the thread belonging to it will be terminated when it exits.  The thread can however detach itself from the main thread.</p><p></p><dl><dt><b>Returns</b>:<dd>True if the thread has been detached.</dl><H2>bool <a name="ref17"></a><a name="joinable">joinable</a>()  </H2><p> A detached thread, isn't joinable... there may also be other situations where a thread does not want a parent thread to join onto it.</p><p></p><dl><dt><b>Returns</b>:<dd>True if the thread can be joined with.</dl><H2>bool <a name="ref18"></a><a name="terminated">terminated</a>()  </H2><p> If a thread has terminated its run, this status will be stored for parent threads to examine.</p><p></p><dl><dt><b>Returns</b>:<dd>True if the thread has terminated its running loop. </dl><H2>bool <a name="ref19"></a><a name="exited">exited</a>()  </H2><p> There are several ways, as previously mentioned, for a thread to finish.  One way, is that it uses the 'exit()' call belonging to the class, another that it simply 'returns' from the loop.</p><p></p><dl><dt><b>Returns</b>:<dd>True, if the thread has exited with 'exit'.</dl><H2>cancel_state <a name="ref20"></a><a name="cancelstate">cancelstate</a>()  </H2><p> Return the cancel state of the process.  The process can disable cancelation, which will make it useful to be able to check if it is actually possible to cancel it.  The cancel state can be one of:</p><p> <pre> cancel_enable   - The process can be cancelled. cancel_disable  - The process cannot be cancelled. </pre></p><p></p><dl><dt><b>Returns</b>:<dd>The cancel state.</dl><H2>cancel_type <a name="ref21"></a><a name="canceltype">canceltype</a>()  </H2><p> If cancels occur, the process can treat them in one of two ways.  It can be handled asynchronously, or it can deferred.  Cancel type, is thus one of:</p><p> <pre> cancel_deferred      - Cancels are deferred. cancel_asynchronous  - Asynchronous cancels. </pre></p><p></p><dl><dt><b>Returns</b>:<dd>the cancel type.</dl><H2>int <a name="ref22"></a><a name="joining">joining</a>(int s)  </H2><p> Join this thread, with another thread.  When this thread terminates, the joined process will be signalled to revive it from a slumber, as a result.</p><p></p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">pid</td><td align="left" valign="top">The pid of the process to revive on exit.</td></tr></table></dl><dl><dt><b>Returns</b>:<dd>The pid that was set.</dl><H2>void <a name="ref23"></a><a name="set">set</a>(cancel_state s)  </H2><p> Set the cancelation state for this thread, see <a href="pthread.html#cancelstate">cancelstate</a> for a discussion on the states available.</p><H2>void <a name="ref24"></a><a name="set">set</a>(cancel_type t)  </H2><p> Set the cancelation type for this thread, see <a href="pthread.html#canceltype">canceltype</a> for a discussion on the types that are available.</p><H2>void <a name="ref25"></a><a name="set">set</a>(jumps, sigjmp_buf *)  </H2><p> Set the points to jump to, on cancel or signal signals.  The jump types are:</p><p> <pre> cancel_jmp   - When a cancel signal occurs. signal_jmp   - On a normal signal. </pre></p><p></p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">sigjmp</td><td align="left" valign="top">The jump point to set.</td></tr><tr><td align="left" valign="top">jump</td><td align="left" valign="top">the jump kind, as above.</td></tr></table></dl><H2>void <a name="ref26"></a><a name="set">set</a>(booleans, bool)  </H2><p> Set any of the boolean variables this thread contains.  The following are for use:</p><p> <pre> set_canceled       - Signify cancel state. set_terminated     - Signify termination state. set_detached       - Signify detached state. set_exited         - Signify exited state. </pre>  The state can only be set, by the process owner.  In this case, the thread itself.</p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">type</td><td align="left" valign="top">The type, as above.</td></tr><tr><td align="left" valign="top">bool</td><td align="left" valign="top">A boolean value, to set to.</td></tr></table></dl><H2>void <a name="ref27"></a><a name="cancel">cancel</a>()  </H2><p> Cancel the process.  This will halt the threads execution, set the cancel state to cancel.  If the cancel type is asynchronous, it will also exit the main loop with an exit value of -1, else if the cancel type is deferred it will jump to a location specified.</p><H2>void <a name="ref28"></a><a name="suspend">suspend</a>()  </H2><p> Suspend the process.  The process is halted, but not terminated... a suspended process cannot be cancelled, unless it has been suspended with that in mind see pthread::suspend_with_cancellation  The process will be restarted,  upon receiving a restart signal see <a href="pthread.html#restart">restart</a> </p><H2>void <a name="ref29"></a><a name="suspend_with_cancelation">suspend_with_cancelation</a>()  </H2><p> suspend the calling process, until it is cancelled or receives a signal.  This does the same thing as <a href="pthread.html#suspend">suspend</a>  but unlike it, the thread can be cancelled when waiting for a signal inside this function.</p><H2>void <a name="ref30"></a><a name="restart">restart</a>()  </H2><p> restart the thread, associated with the class instance.  This will in effect send a SIGUSR1 signal to the process, which will wake it up, if it is in a suspended state or otherwise won't do a thing.</p><H2>void <a name="ref31"></a><a name="jump">jump</a>(jumps)  </H2><p> Jump to a given location, look at <a href="pthread.html#set">set</a> for a discussion on how to set the location to jump to.</p><H2>void <a name="ref32"></a><a name="exit">exit</a>(void *)  </H2><p> exit the process, with a given return value.  This will only work if the calling process is the same as the thread running inside the class instance.  Calling this function from a parent thread, will not have any effect on this class's thread but rather on the calling thread.</p><H2>void <a name="ref33"></a><a name="exit">exit</a>(int)  </H2><p> exit the process as above, but give a retcode as a result insteaad of a pointer to a return value.</p><H2>void <a name="ref34"></a><a name="exit">exit</a>()  </H2><p> exit the process as above, but give the normal zero return value.</p><H2>int <a name="ref35"></a><a name="retcode">retcode</a>()  </H2><p> If a thread exits with 'return val' from inside the thread function, the return value will be stored and retreivable through this function.</p><p></p><dl><dt><b>Returns</b>:<dd>The return value of the thread.</dl><H2>bool <a name="ref36"></a><a name="running">running</a>()  </H2><p> Tell if the process of the thread instance is running.  This function is really not very useful, it calls the scheduler to see if it has the thread scheduled.  Which the scheduler does, even if the thread is a zombie.  See <a href="pthread.html#terminated">terminated</a>  and pthread::cancelled for different methods in determining wether the thread is still alive.</p><H2>int <a name="ref37"></a><a name="join">join</a>()  </H2><p> Join the calling process, with the thread instance.  This will suspend the calling process, until the thread has terminated.  The call can return one of the following error values:</p><p> <pre>  EDLCK         - Dead lock would occur.  ESRCH         - The process is not in the list.  EINVAL        - The thread is detached, or already joining another.  0             - The thread has terminated. </pre></p><dl><dt><b>Returns</b>:<dd>err A value, as seen above.</dl><H2>static void <a name="ref38"></a><a name="set_project">set_project</a>(const char *)  </H2><p> In a shared environment, each process must have it's system wide project name that uniquely identifies it and enables other processes to identify its resources for sharing.  This method is provided to change the current project identity to your hearts desire.</p><p> Note: these project id's will be created as filenames inside the tmp directory, during the process run.  This is done because the shared memory key scheme want's an inode number for use in shared memory key creation.</p><p></p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">str</td><td align="left" valign="top">A C string, giving the name of a common project.</td></tr></table></dl><H2>static void <a name="ref39"></a><a name="set_permission">set_permission</a>(int)  </H2><p> In creating a project, the default permission scheme used is RW-R--R-- i.e. Read Write for the user, and Read permission for everyone else.  The user however, may want a different scheme in sharing his pages, for which purpose this is provided.</p><p></p><dl><dt><b>Parameters</b>:<dd><table width="100%" border="0"><tr><td align="left" valign="top">perm</td><td align="left" valign="top">The integer permission, 9 bits of this value are used.</td></tr></table></dl><HR><TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top"><UL><LI><I>Author</I>: Orn Hansen &lt;oe.hansen@gamma.telenordia.se&gt; Orn 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 + -