📄 pthread_cond_destroy.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>pthread_cond_init</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_1243"> </a>NAME</h4><blockquote>pthread_cond_init, pthread_cond_destroy - initialise and destroycondition variables</blockquote><h4><a name = "tag_000_007_1244"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="pthread.h.html">pthread.h</a>>int pthread_cond_init(pthread_cond_t *<i>cond</i>, const pthread_condattr_t *<i>attr</i>);int pthread_cond_destroy(pthread_cond_t *<i>cond</i>);pthread_cond_t <i>cond</i> = PTHREAD_COND_INITIALIZER;</code></pre></blockquote><h4><a name = "tag_000_007_1245"> </a>DESCRIPTION</h4><blockquote>The function<i>pthread_cond_init()</i>initialises the condition variable referenced by<i>cond</i>with attributes referenced by<i>attr</i>.If<i>attr</i>is NULL,the default condition variable attributes are used;the effect is the same as passing the addressof a default condition variable attributes object.Upon successful initialisation,the state of the condition variable becomes initialised.<p>Attempting to initialise an already initialisedcondition variableresults in undefined behaviour.<p>The function<i>pthread_cond_destroy()</i>destroys the given condition variable specified by<i>cond</i>;the object becomes, in effect, uninitialised.An implementation may cause<i>pthread_cond_destroy()</i>to set the object referenced by<i>cond</i>to an invalid value.A destroyed condition variable objectcan be re-initialised using<i>pthread_cond_init()</i>;the results of otherwise referencing the object after it has been destroyedare undefined.<p>It is safe to destroy an initialised condition variableupon which no threads are currently blocked.Attempting to destroy a condition variableupon which other threads are currently blockedresults in undefined behaviour.<p>In cases where default condition variable attributes are appropriate,the macro PTHREAD_COND_INITIALIZERcan be used to initialise condition variables that are statically allocated.The effect is equivalent to dynamic initialisation by a call to<i>pthread_cond_init()</i>with parameter<i>attr</i>specified as NULL, except that no error checks are performed.</blockquote><h4><a name = "tag_000_007_1246"> </a>RETURN VALUE</h4><blockquote>If successful, the<i>pthread_cond_init()</i>and<i>pthread_cond_destroy()</i>functions return zero.Otherwise, an error number is returned to indicate the error.The [EBUSY] and [EINVAL]error checks, if implemented,act as if they were performed immediatelyat the beginning of processing for the functionand caused an error returnprior to modifying the state of the condition variable specified by<i>cond</i>.</blockquote><h4><a name = "tag_000_007_1247"> </a>ERRORS</h4><blockquote>The <i>pthread_cond_init()</i>function will fail if:<dl compact><dt>[EAGAIN]<dd>The system lacked the necessary resources (otherthan memory) to initialise another condition variable.<dt>[ENOMEM]<dd>Insufficient memory exists to initialise the condition variable.</dl><p>The<i>pthread_cond_init()</i>function may fail if:<dl compact><dt>[EBUSY]<dd>The implementation has detected an attemptto re-initialise the object referenced by<i>cond</i>,a previously initialised, butnot yet destroyed, condition variable.<dt>[EINVAL]<dd>The value specified by<i>attr</i>is invalid.</dl><br><p>The<i>pthread_cond_destroy()</i>function may fail if:<dl compact><dt>[EBUSY]<dd>The implementation has detected an attempt to destroythe object referenced by<i>cond</i>while it is referenced(for example, while being used in a<i><a href="pthread_cond_wait.html">pthread_cond_wait()</a></i>or<i><a href="pthread_cond_timedwait.html">pthread_cond_timedwait()</a></i>)by another thread.<dt>[EINVAL]<dd>The value specified by<i>cond</i>is invalid.</dl><p>These functions will not return an error code of [EINTR].</blockquote><h4><a name = "tag_000_007_1248"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1249"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1250"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1251"> </a>SEE ALSO</h4><blockquote><i><a href="pthread_cond_signal.html">pthread_cond_signal()</a></i>,<i><a href="pthread_cond_broadcast.html">pthread_cond_broadcast()</a></i>,<i><a href="pthread_cond_wait.html">pthread_cond_wait()</a></i>,<i><a href="pthread_cond_timedwait.html">pthread_cond_timedwait()</a></i>,<i><a href="pthread.h.html"><pthread.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX Threads Extension (1003.1c-1995)</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -