Changeset 809
- Timestamp:
- Nov 21, 2006 8:36:12 AM (18 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool.h
r736 r809 796 796 * Internal pool. 797 797 */ 798 pj_pool_t *pool;798 char pool_buf[256]; 799 799 800 800 /** 801 801 * Mutex. 802 802 */ 803 pj_ mutex_t *mutex;803 pj_lock_t *lock; 804 804 }; 805 805 -
pjproject/trunk/pjlib/src/pj/pool_caching.c
r684 r809 21 21 #include <pj/string.h> 22 22 #include <pj/assert.h> 23 #include <pj/lock.h> 23 24 #include <pj/os.h> 25 #include <pj/pool_buf.h> 24 26 25 27 #if !PJ_HAS_POOL_ALT_API … … 53 55 { 54 56 int i; 57 pj_pool_t *pool; 55 58 56 59 PJ_CHECK_STACK(); … … 70 73 cp->factory.on_block_free = &cpool_on_block_free; 71 74 72 cp->pool = pj_pool_create_int(&cp->factory, "cachingpool", 512, 73 0, NULL); 74 i = pj_mutex_create_simple(cp->pool, "cachingpool", &cp->mutex); 75 pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf)); 76 pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock); 75 77 } 76 78 … … 102 104 } 103 105 104 pj_mutex_destroy(cp->mutex); 106 if (cp->lock) { 107 pj_lock_destroy(cp->lock); 108 pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock); 109 } 105 110 } 106 111 … … 117 122 PJ_CHECK_STACK(); 118 123 119 pj_ mutex_lock(cp->mutex);124 pj_lock_acquire(cp->lock); 120 125 121 126 /* Use pool factory's policy when callback is NULL */ … … 154 159 increment_sz, callback); 155 160 if (!pool) { 156 pj_ mutex_unlock(cp->mutex);161 pj_lock_release(cp->lock); 157 162 return NULL; 158 163 } … … 181 186 ++cp->used_count; 182 187 183 pj_ mutex_unlock(cp->mutex);188 pj_lock_release(cp->lock); 184 189 return pool; 185 190 } … … 193 198 PJ_CHECK_STACK(); 194 199 195 pj_ mutex_lock(cp->mutex);200 pj_lock_acquire(cp->lock); 196 201 197 202 /* Erase from the used list. */ … … 211 216 { 212 217 pj_pool_destroy_int(pool); 213 pj_ mutex_unlock(cp->mutex);218 pj_lock_release(cp->lock); 214 219 return; 215 220 } … … 232 237 /* Something has gone wrong with the pool. */ 233 238 pj_pool_destroy_int(pool); 234 pj_ mutex_unlock(cp->mutex);239 pj_lock_release(cp->lock); 235 240 return; 236 241 } … … 239 244 cp->capacity += pool_capacity; 240 245 241 pj_ mutex_unlock(cp->mutex);246 pj_lock_release(cp->lock); 242 247 } 243 248 … … 247 252 pj_caching_pool *cp = (pj_caching_pool*)factory; 248 253 249 pj_ mutex_lock(cp->mutex);254 pj_lock_acquire(cp->lock); 250 255 251 256 PJ_LOG(3,("cachpool", " Dumping caching pool:")); … … 272 277 } 273 278 274 pj_ mutex_unlock(cp->mutex);279 pj_lock_release(cp->lock); 275 280 #else 276 281 PJ_UNUSED_ARG(factory);
Note: See TracChangeset
for help on using the changeset viewer.