Changeset 4567
- Timestamp:
- 02/10/07 01:42:57 (2 years ago)
- Files:
-
- libwired/trunk/libwired/base/wi-pool.c (modified) (6 diffs)
- libwired/trunk/libwired/base/wi-pool.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/base/wi-pool.c
r4511 r4567 76 76 static void _wi_pool_add_pool(wi_pool_t *); 77 77 static wi_pool_t * _wi_pool_pool(void); 78 static void _wi_pool_drain_pool(wi_pool_t *); 78 79 static void _wi_pool_remove_pool(wi_pool_t *); 79 static void _wi_pool_pop_pool(wi_pool_t *);80 80 81 81 … … 122 122 _wi_pool_add_pool(pool); 123 123 124 pool->array = wi_malloc(sizeof(_wi_pool_array_t));125 126 124 return pool; 127 125 } … … 130 128 131 129 static void _wi_pool_dealloc(wi_runtime_instance_t *instance) { 132 wi_pool_t *pool = instance;133 _wi_pool_array_t *array, *next_array;134 130 wi_pool_t *pool = instance; 131 132 _wi_pool_drain_pool(pool); 135 133 _wi_pool_remove_pool(pool); 136 _wi_pool_pop_pool(pool); 137 138 for(array = pool->array; array; array = next_array) { 139 next_array = array->next; 140 wi_free(array); 141 } 134 142 135 } 143 136 … … 186 179 187 180 181 static void _wi_pool_drain_pool(wi_pool_t *pool) { 182 wi_runtime_instance_t **instances; 183 _wi_pool_array_t *array, *next_array; 184 wi_uinteger_t i, length; 185 186 for(array = pool->array; array; array = next_array) { 187 next_array = array->next; 188 length = array->length; 189 instances = array->instances; 190 191 for(i = 0; i < length; i++) 192 wi_release(*instances++); 193 194 wi_free(array); 195 } 196 197 pool->count = 0; 198 pool->array = NULL; 199 } 200 201 202 188 203 static void _wi_pool_remove_pool(wi_pool_t *pool) { 189 204 wi_thread_t *thread; … … 220 235 221 236 222 static void _wi_pool_pop_pool(wi_pool_t *pool) { 223 wi_runtime_instance_t **instances; 224 _wi_pool_array_t *array; 225 wi_uinteger_t i, length; 226 227 for(array = pool->array; array; array = array->next) { 228 length = array->length; 229 instances = array->instances; 230 231 for(i = 0; i < length; i++) 232 wi_release(*instances++); 233 } 234 } 235 236 237 238 #pragma mark - 237 #pragma mark - 238 239 void wi_pool_drain(wi_pool_t *pool) { 240 _wi_pool_drain_pool(pool); 241 } 242 243 239 244 240 245 wi_uinteger_t wi_pool_count(wi_pool_t *pool) { … … 263 268 } 264 269 270 if(!pool->array) 271 pool->array = wi_malloc(sizeof(_wi_pool_array_t)); 272 265 273 array = pool->array; 266 274 libwired/trunk/libwired/base/wi-pool.h
r4437 r4567 41 41 WI_EXPORT wi_pool_t * wi_pool_init(wi_pool_t *); 42 42 43 WI_EXPORT void wi_pool_drain(wi_pool_t *); 43 44 WI_EXPORT wi_uinteger_t wi_pool_count(wi_pool_t *); 44 45
