tb_void_t tb_list_clear(tb_list_ref_t self) { // check tb_list_t* list = (tb_list_t*)self; tb_assert_and_check_return(list); // clear pool if (list->pool) tb_fixed_pool_clear(list->pool); // clear head tb_list_entry_clear(&list->head); }
tb_void_t tb_small_pool_clear(tb_small_pool_ref_t pool) { // check tb_small_pool_impl_t* impl = (tb_small_pool_impl_t*)pool; tb_assert_and_check_return(impl && impl->large_pool); // clear fixed pool tb_size_t i = 0; tb_size_t n = tb_arrayn(impl->fixed_pool); for (i = 0; i < n; i++) { // clear it if (impl->fixed_pool[i]) tb_fixed_pool_clear(impl->fixed_pool[i]); } }
tb_void_t gb_mesh_face_list_clear(gb_mesh_face_list_ref_t list) { // check gb_mesh_face_list_impl_t* impl = (gb_mesh_face_list_impl_t*)list; tb_assert_and_check_return(impl); // clear pool if (impl->pool) tb_fixed_pool_clear(impl->pool); // clear head tb_list_entry_clear(&impl->head); #ifdef __gb_debug__ // clear id impl->id = 0; #endif }
tb_void_t tb_aiop_cler(tb_aiop_ref_t aiop) { // check tb_aiop_impl_t* impl = (tb_aiop_impl_t*)aiop; tb_assert_and_check_return(impl); // clear reactor if (impl->rtor && impl->rtor->cler) impl->rtor->cler(impl->rtor); // clear pool tb_spinlock_enter(&impl->lock); if (impl->pool) tb_fixed_pool_clear(impl->pool); tb_spinlock_leave(&impl->lock); // addo spak if (impl->spak[1]) tb_aiop_addo(aiop, impl->spak[1], TB_AIOE_CODE_RECV, tb_null); }
tb_void_t tb_fixed_pool_exit(tb_fixed_pool_ref_t pool) { // check tb_fixed_pool_impl_t* impl = (tb_fixed_pool_impl_t*)pool; tb_assert_and_check_return(impl); // clear it tb_fixed_pool_clear(pool); // exit the slot list if (impl->slot_list) tb_large_pool_free(tb_large_pool(), impl->slot_list); impl->slot_list = tb_null; impl->slot_count = 0; impl->slot_space = 0; // exit it tb_large_pool_free(tb_large_pool(), impl); }
tb_void_t tb_timer_clear(tb_timer_ref_t timer) { tb_timer_impl_t* impl = (tb_timer_impl_t*)timer; if (impl) { // enter tb_spinlock_enter(&impl->lock); // clear heap if (impl->heap) tb_heap_clear(impl->heap); // clear pool if (impl->pool) tb_fixed_pool_clear(impl->pool); // leave tb_spinlock_leave(&impl->lock); } }
tb_void_t tb_fixed_pool_exit(tb_fixed_pool_ref_t self) { // check tb_fixed_pool_t* pool = (tb_fixed_pool_t*)self; tb_assert_and_check_return(pool); // clear it tb_fixed_pool_clear(self); // exit the current slot if (pool->current_slot) tb_fixed_pool_slot_exit(pool, pool->current_slot); pool->current_slot = tb_null; // exit the slot list if (pool->slot_list) tb_allocator_large_free(pool->large_allocator, pool->slot_list); pool->slot_list = tb_null; pool->slot_count = 0; pool->slot_space = 0; // exit it tb_allocator_large_free(pool->large_allocator, pool); }