aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llapr.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llcommon/llapr.h74
1 files changed, 4 insertions, 70 deletions
diff --git a/linden/indra/llcommon/llapr.h b/linden/indra/llcommon/llapr.h
index 2aed515..ded15f5 100644
--- a/linden/indra/llcommon/llapr.h
+++ b/linden/indra/llcommon/llapr.h
@@ -48,73 +48,8 @@
48#include "apr_atomic.h" 48#include "apr_atomic.h"
49#include "llstring.h" 49#include "llstring.h"
50 50
51extern LL_COMMON_API apr_thread_mutex_t* gLogMutexp; 51class AIAPRPool;
52 52class AIVolatileAPRPool;
53/**
54 * @brief initialize the common apr constructs -- apr itself, the
55 * global pool, and a mutex.
56 */
57void LL_COMMON_API ll_init_apr();
58
59/**
60 * @brief Cleanup those common apr constructs.
61 */
62void LL_COMMON_API ll_cleanup_apr();
63
64//
65//LL apr_pool
66//manage apr_pool_t, destroy allocated apr_pool in the destruction function.
67//
68class LL_COMMON_API LLAPRPool
69{
70public:
71 LLAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE) ;
72 ~LLAPRPool() ;
73
74 apr_pool_t* getAPRPool() ;
75 apr_status_t getStatus() {return mStatus ; }
76
77protected:
78 void releaseAPRPool() ;
79 void createAPRPool() ;
80
81protected:
82 apr_pool_t* mPool ; //pointing to an apr_pool
83 apr_pool_t* mParent ; //parent pool
84 apr_size_t mMaxSize ; //max size of mPool, mPool should return memory to system if allocated memory beyond this limit. However it seems not to work.
85 apr_status_t mStatus ; //status when creating the pool
86 BOOL mReleasePoolFlag ; //if set, mPool is destroyed when LLAPRPool is deleted. default value is true.
87};
88
89//
90//volatile LL apr_pool
91//which clears memory automatically.
92//so it can not hold static data or data after memory is cleared
93//
94class LL_COMMON_API LLVolatileAPRPool : protected LLAPRPool
95{
96public:
97 LLVolatileAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE);
98 ~LLVolatileAPRPool(){}
99
100 apr_pool_t* getVolatileAPRPool() ;
101
102 void clearVolatileAPRPool() ;
103
104 BOOL isFull() ;
105 BOOL isEmpty() {return !mNumActiveRef ;}
106
107 static void initLocalAPRFilePool();
108 static void createLocalAPRFilePool();
109 static void destroyLocalAPRFilePool(void* thread_local_data);
110 static LLVolatileAPRPool* getLocalAPRFilePool();
111
112private:
113 S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool.
114 S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating.
115
116 static apr_threadkey_t* sLocalAPRFilePoolKey;
117} ;
118 53
119/** 54/**
120 * @class LLScopedLock 55 * @class LLScopedLock
@@ -205,7 +140,8 @@ class LL_COMMON_API LLAPRFile : boost::noncopyable
205 // make this non copyable since a copy closes the file 140 // make this non copyable since a copy closes the file
206private: 141private:
207 apr_file_t* mFile ; 142 apr_file_t* mFile ;
208 LLVolatileAPRPool *mCurrentFilePoolp ; //currently in use apr_pool, could be one of them: sAPRFilePoolp, or a temp pool. 143 AIVolatileAPRPool* mVolatileFilePoolp; // (Thread local) APR pool currently in use.
144 AIAPRPool* mRegularFilePoolp; // ...or a regular pool.
209 145
210public: 146public:
211 enum access_t { 147 enum access_t {
@@ -260,6 +196,4 @@ bool LL_COMMON_API ll_apr_warn_status(apr_status_t status);
260 196
261void LL_COMMON_API ll_apr_assert_status(apr_status_t status); 197void LL_COMMON_API ll_apr_assert_status(apr_status_t status);
262 198
263extern "C" LL_COMMON_API apr_pool_t* gAPRPoolp; // Global APR memory pool
264
265#endif // LL_LLAPR_H 199#endif // LL_LLAPR_H