apr_thread_cond.h

説明を見る。
00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_THREAD_COND_H
00018 #define APR_THREAD_COND_H
00019 
00020 /**
00021  * @file apr_thread_cond.h
00022  * @brief APR Condition Variable Routines
00023  */
00024 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 #include "apr_errno.h"
00028 #include "apr_time.h"
00029 #include "apr_thread_mutex.h"
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif /* __cplusplus */
00034 
00035 #if APR_HAS_THREADS || defined(DOXYGEN)
00036 
00037 /**
00038  * @defgroup apr_thread_cond Condition Variable Routines
00039  * @ingroup APR 
00040  * @{
00041  */
00042 
00043 /** Opaque structure for thread condition variables */
00044 typedef struct apr_thread_cond_t apr_thread_cond_t;
00045 
00046 /**
00047  * Note: destroying a condition variable (or likewise, destroying or
00048  * clearing the pool from which a condition variable was allocated) if
00049  * any threads are blocked waiting on it gives undefined results.
00050  */
00051 
00052 /**
00053  * Create and initialize a condition variable that can be used to signal
00054  * and schedule threads in a single process.
00055  * @param cond the memory address where the newly created condition variable
00056  *        will be stored.
00057  * @param pool the pool from which to allocate the mutex.
00058  */
00059 APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
00060                                                  apr_pool_t *pool);
00061 
00062 /**
00063  * Put the active calling thread to sleep until signaled to wake up. Each
00064  * condition variable must be associated with a mutex, and that mutex must
00065  * be locked before  calling this function, or the behavior will be
00066  * undefined. As the calling thread is put to sleep, the given mutex
00067  * will be simultaneously released; and as this thread wakes up the lock
00068  * is again simultaneously acquired.
00069  * @param cond the condition variable on which to block.
00070  * @param mutex the mutex that must be locked upon entering this function,
00071  *        is released while the thread is asleep, and is again acquired before
00072  *        returning from this function.
00073  */
00074 APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
00075                                                apr_thread_mutex_t *mutex);
00076 
00077 /**
00078  * Put the active calling thread to sleep until signaled to wake up or
00079  * the timeout is reached. Each condition variable must be associated
00080  * with a mutex, and that mutex must be locked before calling this
00081  * function, or the behavior will be undefined. As the calling thread
00082  * is put to sleep, the given mutex will be simultaneously released;
00083  * and as this thread wakes up the lock is again simultaneously acquired.
00084  * @param cond the condition variable on which to block.
00085  * @param mutex the mutex that must be locked upon entering this function,
00086  *        is released while the thread is asleep, and is again acquired before
00087  *        returning from this function.
00088  * @param timeout The amount of time in microseconds to wait. This is 
00089  *        a maximum, not a minimum. If the condition is signaled, we 
00090  *        will wake up before this time, otherwise the error APR_TIMEUP
00091  *        is returned.
00092  */
00093 APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
00094                                                     apr_thread_mutex_t *mutex,
00095                                                     apr_interval_time_t timeout);
00096 
00097 /**
00098  * Signals a single thread, if one exists, that is blocking on the given
00099  * condition variable. That thread is then scheduled to wake up and acquire
00100  * the associated mutex. Although it is not required, if predictable scheduling
00101  * is desired, that mutex must be locked while calling this function.
00102  * @param cond the condition variable on which to produce the signal.
00103  */
00104 APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond);
00105 
00106 /**
00107  * Signals all threads blocking on the given condition variable.
00108  * Each thread that was signaled is then scheduled to wake up and acquire
00109  * the associated mutex. This will happen in a serialized manner.
00110  * @param cond the condition variable on which to produce the broadcast.
00111  */
00112 APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond);
00113 
00114 /**
00115  * Destroy the condition variable and free the associated memory.
00116  * @param cond the condition variable to destroy.
00117  */
00118 APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond);
00119 
00120 /**
00121  * Get the pool used by this thread_cond.
00122  * @return apr_pool_t the pool
00123  */
00124 APR_POOL_DECLARE_ACCESSOR(thread_cond);
00125 
00126 #endif /* APR_HAS_THREADS */
00127 
00128 /** @} */
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 
00134 #endif  /* ! APR_THREAD_COND_H */

Apache Portable Runtimeに対してSun Jul 19 22:04:00 2009に生成されました。  doxygen 1.4.7