Changeset 232
- Timestamp:
- Feb 26, 2006 9:18:42 PM (19 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool.h
r69 r232 543 543 */ 544 544 pj_list used_list; 545 546 /** 547 * Internal pool. 548 */ 549 pj_pool_t *pool; 550 551 /** 552 * Mutex. 553 */ 554 pj_mutex_t *mutex; 545 555 }; 546 556 -
pjproject/trunk/pjlib/src/pj/pool_caching.c
r108 r232 57 57 cp->factory.release_pool = &cpool_release_pool; 58 58 cp->factory.dump_status = &cpool_dump_status; 59 60 cp->pool = pj_pool_create_int(&cp->factory, "cachingpool", 128, 61 0, NULL); 62 i = pj_mutex_create_simple(cp->pool, "cachingpool", &cp->mutex); 59 63 } 60 64 … … 85 89 pool = next; 86 90 } 91 92 pj_mutex_destroy(cp->mutex); 87 93 } 88 94 … … 98 104 99 105 PJ_CHECK_STACK(); 106 107 pj_mutex_lock(cp->mutex); 100 108 101 109 /* Use pool factory's policy when callback is NULL */ … … 124 132 pool = pj_pool_create_int(&cp->factory, name, initial_size, 125 133 increment_sz, callback); 126 if (!pool) 134 if (!pool) { 135 pj_mutex_unlock(cp->mutex); 127 136 return NULL; 137 } 128 138 129 139 } else { … … 146 156 /* Increment used count. */ 147 157 ++cp->used_count; 158 159 pj_mutex_unlock(cp->mutex); 148 160 return pool; 149 161 } … … 155 167 156 168 PJ_CHECK_STACK(); 169 170 pj_mutex_lock(cp->mutex); 157 171 158 172 /* Erase from the used list. */ … … 170 184 { 171 185 pj_pool_destroy_int(pool); 186 pj_mutex_unlock(cp->mutex); 172 187 return; 173 188 } … … 189 204 /* Something has gone wrong with the pool. */ 190 205 pj_pool_destroy_int(pool); 206 pj_mutex_unlock(cp->mutex); 191 207 return; 192 208 } … … 194 210 pj_list_insert_after(&cp->free_list[i], pool); 195 211 cp->capacity += pool->capacity; 212 213 pj_mutex_unlock(cp->mutex); 196 214 } 197 215 … … 200 218 #if PJ_LOG_MAX_LEVEL >= 3 201 219 pj_caching_pool *cp = (pj_caching_pool*)factory; 220 221 pj_mutex_lock(cp->mutex); 222 202 223 PJ_LOG(3,("cachpool", " Dumping caching pool:")); 203 224 PJ_LOG(3,("cachpool", " Capacity=%u, max_capacity=%u, used_cnt=%u", \ … … 219 240 total_used * 100 / total_capacity)); 220 241 } 242 243 pj_mutex_unlock(cp->mutex); 221 244 #else 222 245 PJ_UNUSED_ARG(factory);
Note: See TracChangeset
for help on using the changeset viewer.