예제 #1
0
static void
hrt_task_runner_dispose(GObject *object)
{
    HrtTaskRunner *runner;

    runner = HRT_TASK_RUNNER(object);

    if (runner->event_loop) {
        HrtEventLoop *loop = runner->event_loop;

        runner->event_loop = NULL;

        /* loop should already be running so this returns immediately,
         * or if things are broken it hangs here which should give a
         * clear backtrace showing the problem.
         */
        _hrt_event_loop_wait_running(loop, TRUE);

        _hrt_event_loop_quit(loop);

        /* this isn't really needed, we could just join the thread,
         * but this gives a clearer backtrace if things go wrong and
         * we don't quit.
         */
        _hrt_event_loop_wait_running(loop, FALSE);

        g_thread_join(runner->event_thread);
        runner->event_thread = NULL;

        g_object_unref(loop);
    }

    if (runner->invoke_threads) {
        hrt_thread_pool_shutdown(runner->invoke_threads);
        g_object_unref(runner->invoke_threads);
        runner->invoke_threads = NULL;
    }

    /* the definition of dispose would usually involve freeing
     * everything in completed_tasks but we wait for the idle
     * to do that to be sure it's in the right thread. In the
     * meantime there should be a ref held by the idle preventing
     * finalization.
     */

    G_OBJECT_CLASS(hrt_task_runner_parent_class)->dispose(object);
}
예제 #2
0
static void
hrt_thread_pool_dispose(GObject *object)
{
    HrtThreadPool *pool;

    pool = HRT_THREAD_POOL(object);

    hrt_thread_pool_shutdown(pool);

    if (pool->vfunc_data_dnotify != NULL) {

        (* pool->vfunc_data_dnotify) (pool->vfunc_data);
    }

    pool->vtable = NULL;
    pool->vfunc_data = NULL;
    pool->vfunc_data_dnotify = NULL;

    G_OBJECT_CLASS(hrt_thread_pool_parent_class)->dispose(object);
}