📄 apr__thread__rwlock_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Apache Portable Runtime: apr_thread_rwlock.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>apr_thread_rwlock.h</h1><a href="apr__thread__rwlock_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="comment">/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as</span>
00002 <span class="comment"> * applicable.</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
00006 <span class="comment"> * You may obtain a copy of the License at</span>
00007 <span class="comment"> *</span>
00008 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span>
00009 <span class="comment"> *</span>
00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
00014 <span class="comment"> * limitations under the License.</span>
00015 <span class="comment"> */</span>
00016
00017 <span class="preprocessor">#ifndef APR_THREAD_RWLOCK_H</span>
00018 <span class="preprocessor"></span><span class="preprocessor">#define APR_THREAD_RWLOCK_H</span>
00019 <span class="preprocessor"></span><span class="comment"></span>
00020 <span class="comment">/**</span>
00021 <span class="comment"> * @file apr_thread_rwlock.h</span>
00022 <span class="comment"> * @brief APR Reader/Writer Lock Routines</span>
00023 <span class="comment"> */</span>
00024
00025 <span class="preprocessor">#include "apr.h"</span>
00026 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span>
00027 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span>
00028
00029 <span class="preprocessor">#ifdef __cplusplus</span>
00030 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
00031 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span>
00032
00033 <span class="preprocessor">#if APR_HAS_THREADS</span>
00034 <span class="preprocessor"></span><span class="comment"></span>
00035 <span class="comment">/**</span>
00036 <span class="comment"> * @defgroup apr_thread_rwlock Reader/Writer Lock Routines</span>
00037 <span class="comment"> * @ingroup APR </span>
00038 <span class="comment"> * @{</span>
00039 <span class="comment"> */</span>
00040 <span class="comment"></span>
00041 <span class="comment">/** Opaque read-write thread-safe lock. */</span>
<a name="l00042"></a><a class="code" href="group__apr__thread__rwlock.html#ga0">00042</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__apr__thread__rwlock.html#ga0">apr_thread_rwlock_t</a> <a class="code" href="group__apr__thread__rwlock.html#ga0">apr_thread_rwlock_t</a>;
00043 <span class="comment"></span>
00044 <span class="comment">/**</span>
00045 <span class="comment"> * Note: The following operations have undefined results: unlocking a</span>
00046 <span class="comment"> * read-write lock which is not locked in the calling thread; write</span>
00047 <span class="comment"> * locking a read-write lock which is already locked by the calling</span>
00048 <span class="comment"> * thread; destroying a read-write lock more than once; clearing or</span>
00049 <span class="comment"> * destroying the pool from which a <b>locked</b> read-write lock is</span>
00050 <span class="comment"> * allocated.</span>
00051 <span class="comment"> */</span>
00052 <span class="comment"></span>
00053 <span class="comment">/**</span>
00054 <span class="comment"> * Create and initialize a read-write lock that can be used to synchronize</span>
00055 <span class="comment"> * threads.</span>
00056 <span class="comment"> * @param rwlock the memory address where the newly created readwrite lock</span>
00057 <span class="comment"> * will be stored.</span>
00058 <span class="comment"> * @param pool the pool from which to allocate the mutex.</span>
00059 <span class="comment"> */</span>
00060 APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
00061 apr_pool_t *pool);<span class="comment"></span>
00062 <span class="comment">/**</span>
00063 <span class="comment"> * Acquire a shared-read lock on the given read-write lock. This will allow</span>
00064 <span class="comment"> * multiple threads to enter the same critical section while they have acquired</span>
00065 <span class="comment"> * the read lock.</span>
00066 <span class="comment"> * @param rwlock the read-write lock on which to acquire the shared read.</span>
00067 <span class="comment"> */</span>
00068 APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock);
00069 <span class="comment"></span>
00070 <span class="comment">/**</span>
00071 <span class="comment"> * Attempt to acquire the shared-read lock on the given read-write lock. This</span>
00072 <span class="comment"> * is the same as apr_thread_rwlock_rdlock(), only that the function fails</span>
00073 <span class="comment"> * if there is another thread holding the write lock, or if there are any</span>
00074 <span class="comment"> * write threads blocking on the lock. If the function fails for this case,</span>
00075 <span class="comment"> * APR_EBUSY will be returned. Note: it is important that the</span>
00076 <span class="comment"> * APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was</span>
00077 <span class="comment"> * APR_EBUSY, for portability reasons.</span>
00078 <span class="comment"> * @param rwlock the rwlock on which to attempt the shared read.</span>
00079 <span class="comment"> */</span>
00080 APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock);
00081 <span class="comment"></span>
00082 <span class="comment">/**</span>
00083 <span class="comment"> * Acquire an exclusive-write lock on the given read-write lock. This will</span>
00084 <span class="comment"> * allow only one single thread to enter the critical sections. If there</span>
00085 <span class="comment"> * are any threads currently holding the read-lock, this thread is put to</span>
00086 <span class="comment"> * sleep until it can have exclusive access to the lock.</span>
00087 <span class="comment"> * @param rwlock the read-write lock on which to acquire the exclusive write.</span>
00088 <span class="comment"> */</span>
00089 APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock);
00090 <span class="comment"></span>
00091 <span class="comment">/**</span>
00092 <span class="comment"> * Attempt to acquire the exclusive-write lock on the given read-write lock. </span>
00093 <span class="comment"> * This is the same as apr_thread_rwlock_wrlock(), only that the function fails</span>
00094 <span class="comment"> * if there is any other thread holding the lock (for reading or writing),</span>
00095 <span class="comment"> * in which case the function will return APR_EBUSY. Note: it is important</span>
00096 <span class="comment"> * that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return</span>
00097 <span class="comment"> * value was APR_EBUSY, for portability reasons.</span>
00098 <span class="comment"> * @param rwlock the rwlock on which to attempt the exclusive write.</span>
00099 <span class="comment"> */</span>
00100 APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock);
00101 <span class="comment"></span>
00102 <span class="comment">/**</span>
00103 <span class="comment"> * Release either the read or write lock currently held by the calling thread</span>
00104 <span class="comment"> * associated with the given read-write lock.</span>
00105 <span class="comment"> * @param rwlock the read-write lock to be released (unlocked).</span>
00106 <span class="comment"> */</span>
00107 APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock);
00108 <span class="comment"></span>
00109 <span class="comment">/**</span>
00110 <span class="comment"> * Destroy the read-write lock and free the associated memory.</span>
00111 <span class="comment"> * @param rwlock the rwlock to destroy.</span>
00112 <span class="comment"> */</span>
00113 APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock);
00114 <span class="comment"></span>
00115 <span class="comment">/**</span>
00116 <span class="comment"> * Get the pool used by this thread_rwlock.</span>
00117 <span class="comment"> * @return apr_pool_t the pool</span>
00118 <span class="comment"> */</span>
00119 APR_POOL_DECLARE_ACCESSOR(thread_rwlock);
00120
00121 #endif <span class="comment">/* APR_HAS_THREADS */</span>
00122 <span class="comment"></span>
00123 <span class="comment">/** @} */</span>
00124
00125 #ifdef __cplusplus
00126 }
00127 #endif
00128
00129 #endif <span class="comment">/* ! APR_THREAD_RWLOCK_H */</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 7 13:18:25 2005 for Apache Portable Runtime by
<a href="../../../www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -