svn_pools.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  *    Licensed to the Apache Software Foundation (ASF) under one
00005  *    or more contributor license agreements.  See the NOTICE file
00006  *    distributed with this work for additional information
00007  *    regarding copyright ownership.  The ASF licenses this file
00008  *    to you under the Apache License, Version 2.0 (the
00009  *    "License"); you may not use this file except in compliance
00010  *    with the License.  You may obtain a copy of the License at
00011  *
00012  *      http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  *    Unless required by applicable law or agreed to in writing,
00015  *    software distributed under the License is distributed on an
00016  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00017  *    KIND, either express or implied.  See the License for the
00018  *    specific language governing permissions and limitations
00019  *    under the License.
00020  * ====================================================================
00021  * @endcopyright
00022  *
00023  * @file svn_pools.h
00024  * @brief APR pool management for Subversion
00025  */
00026 
00027 
00028 
00029 
00030 #ifndef SVN_POOLS_H
00031 #define SVN_POOLS_H
00032 
00033 #include "svn_types.h"
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif /* __cplusplus */
00038 
00039 
00040 
00041 /* Wrappers around APR pools, so we get debugging. */
00042 
00043 /** The recommended maximum amount of memory (4MB) to keep in an APR
00044  * allocator on the free list, conveniently defined here to share
00045  * between all our applications.
00046  */
00047 #define SVN_ALLOCATOR_RECOMMENDED_MAX_FREE (4096 * 1024)
00048 
00049 
00050 /** Wrapper around apr_pool_create_ex(), with a simpler interface.
00051  * The return pool will have an abort function set, which will call
00052  * abort() on OOM.
00053  */
00054 apr_pool_t *
00055 svn_pool_create_ex(apr_pool_t *parent_pool,
00056                    apr_allocator_t *allocator);
00057 
00058 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00059 apr_pool_t *
00060 svn_pool_create_ex_debug(apr_pool_t *parent_pool,
00061                          apr_allocator_t *allocator,
00062                          const char *file_line);
00063 
00064 #if APR_POOL_DEBUG
00065 #define svn_pool_create_ex(pool, allocator) \
00066 svn_pool_create_ex_debug(pool, allocator, APR_POOL__FILE_LINE__)
00067 
00068 #endif /* APR_POOL_DEBUG */
00069 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00070 
00071 
00072 /** Create a pool as a subpool of @a parent_pool */
00073 #define svn_pool_create(parent_pool) svn_pool_create_ex(parent_pool, NULL)
00074 
00075 /** Clear a @a pool destroying its children.
00076  *
00077  * This define for @c svn_pool_clear exists for completeness.
00078  */
00079 #define svn_pool_clear apr_pool_clear
00080 
00081 
00082 /** Destroy a @a pool and all of its children.
00083  *
00084  * This define for @c svn_pool_destroy exists for symmetry and
00085  * completeness.
00086  */
00087 #define svn_pool_destroy apr_pool_destroy
00088 
00089 /** Return a new allocator.  This function limits the unused memory in the
00090  * new allocator to #SVN_ALLOCATOR_RECOMMENDED_MAX_FREE and ensures
00091  * proper synchronization if the allocator is used by multiple threads.
00092  *
00093  * If your application uses multiple threads, creating a separate
00094  * allocator for each of these threads may not be feasible.  Set the
00095  * @a thread_safe parameter to @c TRUE in that case; otherwise, set @a
00096  * thread_safe to @c FALSE to maximize performance.
00097  *
00098  * @note Even if @a thread_safe is @c TRUE, pools themselves will
00099  * still not be thread-safe and their access may require explicit
00100  * serialization.
00101  *
00102  * To access the owner pool, which can also serve as the root pool for
00103  * your sub-pools, call @c apr_allocator_get_owner().
00104  *
00105  * @since: New in 1.8
00106  */
00107 apr_allocator_t *
00108 svn_pool_create_allocator(svn_boolean_t thread_safe);
00109 
00110 #ifdef __cplusplus
00111 }
00112 #endif /* __cplusplus */
00113 
00114 #endif /* SVN_POOLS_H */

Generated on Thu Dec 1 13:50:05 2016 for Subversion by  doxygen 1.4.7