CF_EXPORT void rwsched_tasklet_CFRunLoopTimerRelease(rwsched_tasklet_ptr_t sched_tasklet, rwsched_CFRunLoopTimerRef rwsched_timer) { // Validate input paraemters RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t); rwsched_instance_ptr_t instance = sched_tasklet->instance; RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t); rwsched_timer->release_called = 1; if (rwsched_timer->index) rwsched_tasklet_CFRunLoopTimerInvalidate(sched_tasklet, rwsched_timer); // Call the native CFRunLoop function CFRelease(rwsched_timer->cf_object); RW_CF_TYPE_FREE(rwsched_timer, rwsched_CFRunLoopTimerRef); rwsched_tasklet_unref(sched_tasklet); rwsched_instance_unref(instance); }
static void rwsched_tasklet_free_int(rwsched_tasklet_t *sched_tasklet) { RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t); rwsched_instance_ptr_t instance = sched_tasklet->instance; RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t); if (!g_atomic_int_dec_and_test(&sched_tasklet->ref_cnt)) { return; } int i; for (i = 0 ; i < RWSCHED_MAX_SIGNALS; i++) { if (sched_tasklet->signal_dtor[i]) { sched_tasklet->signal_dtor[i](sched_tasklet->signal_dtor_ud[i]); } sched_tasklet->signal_dtor[i]= NULL; sched_tasklet->signal_dtor_ud[i]= NULL; } for (i = 1 ; i < instance->tasklet_array->len ; i++) { if (g_array_index(instance->tasklet_array, rwsched_tasklet_ptr_t, i) == sched_tasklet) { g_array_remove_index (instance->tasklet_array, i); break; } } rwsched_CFRunLoopTimerRef rw_timer; while ((rw_timer = g_array_index(sched_tasklet->cftimer_array, rwsched_CFRunLoopTimerRef, 1)) != NULL) { RW_CF_TYPE_VALIDATE(rw_timer, rwsched_CFRunLoopTimerRef); rwsched_tasklet_CFRunLoopTimerInvalidate(sched_tasklet, rw_timer); g_array_remove_index (sched_tasklet->cftimer_array, 1); } g_array_free(sched_tasklet->cftimer_array, TRUE); rwsched_CFSocketRef rw_socket; while ((rw_socket = g_array_index(sched_tasklet->cfsocket_array, rwsched_CFSocketRef, 1)) != NULL) { RW_CF_TYPE_VALIDATE(rw_socket, rwsched_CFSocketRef); rwsched_tasklet_CFSocketRelease(sched_tasklet, rw_socket); //g_array_remove_index (sched_tasklet->cfsocket_array, 1); } g_array_free(sched_tasklet->cfsocket_array, TRUE); rwsched_CFRunLoopSourceRef rw_source; while ((rw_source = g_array_index(sched_tasklet->cfsource_array, rwsched_CFRunLoopSourceRef, 1)) != NULL) { RW_CF_TYPE_VALIDATE(rw_source, rwsched_CFRunLoopSourceRef); rwsched_tasklet_CFSocketReleaseRunLoopSource(sched_tasklet, rw_source); g_array_remove_index (sched_tasklet->cfsource_array, 1); } g_array_free(sched_tasklet->cfsource_array, TRUE); rwsched_dispatch_what_ptr_t what; while ((what = g_array_index(sched_tasklet->dispatch_what_array, rwsched_dispatch_what_ptr_t, 1)) != NULL) { RW_FREE_TYPE(what, rwsched_dispatch_what_ptr_t); g_array_remove_index (sched_tasklet->dispatch_what_array, 1); } g_array_free(sched_tasklet->dispatch_what_array, TRUE); ck_pr_dec_32(&g_rwsched_tasklet_count); //NO-FREE RW_CF_TYPE_FREE(sched_tasklet, rwsched_tasklet_ptr_t); rwsched_instance_unref(instance); }