Adjust fileList from perl
[msysgit.git] / include / apr-0 / apr_thread_rwlock.h
blob0e69a2a497bab0a9fe1ca79af83111de43b878a5
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef APR_THREAD_RWLOCK_H
18 #define APR_THREAD_RWLOCK_H
20 /**
21 * @file apr_thread_rwlock.h
22 * @brief APR Reader/Writer Lock Routines
25 #include "apr.h"
26 #include "apr_pools.h"
27 #include "apr_errno.h"
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
33 #if APR_HAS_THREADS
35 /**
36 * @defgroup apr_thread_rwlock Reader/Writer Lock Routines
37 * @ingroup APR
38 * @{
41 /** Opaque read-write thread-safe lock. */
42 typedef struct apr_thread_rwlock_t apr_thread_rwlock_t;
44 /**
45 * Create and initialize a read-write lock that can be used to synchronize
46 * threads.
47 * @param rwlock the memory address where the newly created readwrite lock
48 * will be stored.
49 * @param pool the pool from which to allocate the mutex.
51 APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
52 apr_pool_t *pool);
53 /**
54 * Acquire a shared-read lock on the given read-write lock. This will allow
55 * multiple threads to enter the same critical section while they have acquired
56 * the read lock.
57 * @param rwlock the read-write lock on which to acquire the shared read.
59 APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock);
61 /**
62 * Attempt to acquire the shread-read lock on the given read-write lock. This
63 * is the same as apr_thread_rwlock_rdlock(), only that the funtion fails
64 * if there is another thread holding the write lock, or if there are any
65 * write threads blocking on the lock. If the function failes for this case,
66 * APR_EBUSY will be returned. Note: it is important that the
67 * APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was
68 * APR_EBUSY, for portability reasons.
69 * @param rwlock the rwlock on which to attempt the shared read.
71 APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock);
73 /**
74 * Acquire an exclusive-write lock on the given read-write lock. This will
75 * allow only one single thread to enter the critical sections. If there
76 * are any threads currently holding thee read-lock, this thread is put to
77 * sleep until it can have exclusive access to the lock.
78 * @param rwlock the read-write lock on which to acquire the exclusive write.
80 APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock);
82 /**
83 * Attempt to acquire the exclusive-write lock on the given read-write lock.
84 * This is the same as apr_thread_rwlock_wrlock(), only that the funtion fails
85 * if there is any other thread holding the lock (for reading or writing),
86 * in which case the function will return APR_EBUSY. Note: it is important
87 * that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return
88 * value was APR_EBUSY, for portability reasons.
89 * @param rwlock the rwlock on which to attempt the exclusive write.
91 APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock);
93 /**
94 * Release either the read or write lock currently held by the calling thread
95 * associated with the given read-write lock.
96 * @param rwlock the read-write lock to be released (unlocked).
98 APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock);
101 * Destroy the read-write lock and free the associated memory.
102 * @param rwlock the rwlock to destroy.
104 APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock);
107 * Get the pool used by this thread_rwlock.
108 * @return apr_pool_t the pool
110 APR_POOL_DECLARE_ACCESSOR(thread_rwlock);
112 #endif /* APR_HAS_THREADS */
114 /** @} */
116 #ifdef __cplusplus
118 #endif
120 #endif /* ! APR_THREAD_RWLOCK_H */