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

« back to all changes in this revision

Viewing changes to srclib/apr/include/apr_thread_mutex.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_MUTEX_H
 
18
#define APR_THREAD_MUTEX_H
 
19
 
 
20
/**
 
21
 * @file apr_thread_mutex.h
 
22
 * @brief APR Thread Mutex Routines
 
23
 */
 
24
 
 
25
#include "apr.h"
 
26
#include "apr_errno.h"
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" {
 
30
#endif /* __cplusplus */
 
31
 
 
32
#if APR_HAS_THREADS || defined(DOXYGEN)
 
33
 
 
34
/**
 
35
 * @defgroup apr_thread_mutex Thread Mutex Routines
 
36
 * @ingroup APR 
 
37
 * @{
 
38
 */
 
39
 
 
40
/** Opaque thread-local mutex structure */
 
41
typedef struct apr_thread_mutex_t apr_thread_mutex_t;
 
42
 
 
43
#define APR_THREAD_MUTEX_DEFAULT  0x0   /**< platform-optimal lock behavior */
 
44
#define APR_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */
 
45
#define APR_THREAD_MUTEX_UNNESTED 0x2   /**< disable nested locks */
 
46
 
 
47
/* Delayed the include to avoid a circular reference */
 
48
#include "apr_pools.h"
 
49
 
 
50
/**
 
51
 * Create and initialize a mutex that can be used to synchronize threads.
 
52
 * @param mutex the memory address where the newly created mutex will be
 
53
 *        stored.
 
54
 * @param flags Or'ed value of:
 
55
 * <PRE>
 
56
 *           APR_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
 
57
 *           APR_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
 
58
 *           APR_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
 
59
 * </PRE>
 
60
 * @param pool the pool from which to allocate the mutex.
 
61
 * @warning Be cautious in using APR_THREAD_MUTEX_DEFAULT.  While this is the
 
62
 * most optimial mutex based on a given platform's performance charateristics,
 
63
 * it will behave as either a nested or an unnested lock.
 
64
 */
 
65
APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
 
66
                                                  unsigned int flags,
 
67
                                                  apr_pool_t *pool);
 
68
/**
 
69
 * Acquire the lock for the given mutex. If the mutex is already locked,
 
70
 * the current thread will be put to sleep until the lock becomes available.
 
71
 * @param mutex the mutex on which to acquire the lock.
 
72
 */
 
73
APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex);
 
74
 
 
75
/**
 
76
 * Attempt to acquire the lock for the given mutex. If the mutex has already
 
77
 * been acquired, the call returns immediately with APR_EBUSY. Note: it
 
78
 * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine
 
79
 * if the return value was APR_EBUSY, for portability reasons.
 
80
 * @param mutex the mutex on which to attempt the lock acquiring.
 
81
 */
 
82
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex);
 
83
 
 
84
/**
 
85
 * Release the lock for the given mutex.
 
86
 * @param mutex the mutex from which to release the lock.
 
87
 */
 
88
APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex);
 
89
 
 
90
/**
 
91
 * Destroy the mutex and free the memory associated with the lock.
 
92
 * @param mutex the mutex to destroy.
 
93
 */
 
94
APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex);
 
95
 
 
96
/**
 
97
 * Get the pool used by this thread_mutex.
 
98
 * @return apr_pool_t the pool
 
99
 */
 
100
APR_POOL_DECLARE_ACCESSOR(thread_mutex);
 
101
 
 
102
#endif /* APR_HAS_THREADS */
 
103
 
 
104
/** @} */
 
105
 
 
106
#ifdef __cplusplus
 
107
}
 
108
#endif
 
109
 
 
110
#endif  /* ! APR_THREAD_MUTEX_H */