~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/include/apr_thread_cond.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#ifndef APR_THREAD_COND_H
 
18
#define APR_THREAD_COND_H
 
19
 
 
20
/**
 
21
 * @file apr_thread_cond.h
 
22
 * @brief APR Condition Variable Routines
 
23
 */
 
24
 
 
25
#include "apr.h"
 
26
#include "apr_pools.h"
 
27
#include "apr_errno.h"
 
28
#include "apr_time.h"
 
29
#include "apr_thread_mutex.h"
 
30
 
 
31
#ifdef __cplusplus
 
32
extern "C" {
 
33
#endif /* __cplusplus */
 
34
 
 
35
#if APR_HAS_THREADS || defined(DOXYGEN)
 
36
 
 
37
/**
 
38
 * @defgroup apr_thread_cond Condition Variable Routines
 
39
 * @ingroup APR 
 
40
 * @{
 
41
 */
 
42
 
 
43
/** Opaque structure for thread condition variables */
 
44
typedef struct apr_thread_cond_t apr_thread_cond_t;
 
45
 
 
46
/**
 
47
 * Note: destroying a condition variable (or likewise, destroying or
 
48
 * clearing the pool from which a condition variable was allocated) if
 
49
 * any threads are blocked waiting on it gives undefined results.
 
50
 */
 
51
 
 
52
/**
 
53
 * Create and initialize a condition variable that can be used to signal
 
54
 * and schedule threads in a single process.
 
55
 * @param cond the memory address where the newly created condition variable
 
56
 *        will be stored.
 
57
 * @param pool the pool from which to allocate the mutex.
 
58
 */
 
59
APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
 
60
                                                 apr_pool_t *pool);
 
61
 
 
62
/**
 
63
 * Put the active calling thread to sleep until signaled to wake up. Each
 
64
 * condition variable must be associated with a mutex, and that mutex must
 
65
 * be locked before  calling this function, or the behavior will be
 
66
 * undefined. As the calling thread is put to sleep, the given mutex
 
67
 * will be simultaneously released; and as this thread wakes up the lock
 
68
 * is again simultaneously acquired.
 
69
 * @param cond the condition variable on which to block.
 
70
 * @param mutex the mutex that must be locked upon entering this function,
 
71
 *        is released while the thread is asleep, and is again acquired before
 
72
 *        returning from this function.
 
73
 */
 
74
APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
 
75
                                               apr_thread_mutex_t *mutex);
 
76
 
 
77
/**
 
78
 * Put the active calling thread to sleep until signaled to wake up or
 
79
 * the timeout is reached. Each condition variable must be associated
 
80
 * with a mutex, and that mutex must be locked before calling this
 
81
 * function, or the behavior will be undefined. As the calling thread
 
82
 * is put to sleep, the given mutex will be simultaneously released;
 
83
 * and as this thread wakes up the lock is again simultaneously acquired.
 
84
 * @param cond the condition variable on which to block.
 
85
 * @param mutex the mutex that must be locked upon entering this function,
 
86
 *        is released while the thread is asleep, and is again acquired before
 
87
 *        returning from this function.
 
88
 * @param timeout The amount of time in microseconds to wait. This is 
 
89
 *        a maximum, not a minimum. If the condition is signaled, we 
 
90
 *        will wake up before this time, otherwise the error APR_TIMEUP
 
91
 *        is returned.
 
92
 */
 
93
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
 
94
                                                    apr_thread_mutex_t *mutex,
 
95
                                                    apr_interval_time_t timeout);
 
96
 
 
97
/**
 
98
 * Signals a single thread, if one exists, that is blocking on the given
 
99
 * condition variable. That thread is then scheduled to wake up and acquire
 
100
 * the associated mutex. Although it is not required, if predictable scheduling
 
101
 * is desired, that mutex must be locked while calling this function.
 
102
 * @param cond the condition variable on which to produce the signal.
 
103
 */
 
104
APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond);
 
105
 
 
106
/**
 
107
 * Signals all threads blocking on the given condition variable.
 
108
 * Each thread that was signaled is then scheduled to wake up and acquire
 
109
 * the associated mutex. This will happen in a serialized manner.
 
110
 * @param cond the condition variable on which to produce the broadcast.
 
111
 */
 
112
APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond);
 
113
 
 
114
/**
 
115
 * Destroy the condition variable and free the associated memory.
 
116
 * @param cond the condition variable to destroy.
 
117
 */
 
118
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond);
 
119
 
 
120
/**
 
121
 * Get the pool used by this thread_cond.
 
122
 * @return apr_pool_t the pool
 
123
 */
 
124
APR_POOL_DECLARE_ACCESSOR(thread_cond);
 
125
 
 
126
#endif /* APR_HAS_THREADS */
 
127
 
 
128
/** @} */
 
129
 
 
130
#ifdef __cplusplus
 
131
}
 
132
#endif
 
133
 
 
134
#endif  /* ! APR_THREAD_COND_H */