static gboolean complete_tasks_in_runner_thread(void *data) { HrtTaskRunner *runner = HRT_TASK_RUNNER(data); HrtTask *task; g_mutex_lock(runner->completed_tasks_lock); /* unlocked_completed_tasks must be empty because we only run one * of these idles at a time, and at the end of the idle we * always empty unlocked_completed_tasks if the app did not. */ g_assert(g_queue_get_length(&runner->unlocked_completed_tasks) == 0); /* just copy entire GQueue by value */ runner->unlocked_completed_tasks = runner->completed_tasks; g_queue_init(&runner->completed_tasks); runner->completed_tasks_idle_id = 0; g_mutex_unlock(runner->completed_tasks_lock); /* During this emission, unlocked_completed_tasks MUST be drained or * else we'll just drop its contents on the floor. */ g_signal_emit(G_OBJECT(runner), signals[TASKS_COMPLETED], 0); /* drop any tasks that weren't taken by the app on the floor */ while ((task = hrt_task_runner_pop_completed(runner)) != NULL) { g_object_unref(task); } return FALSE; }
static void on_tasks_completed(HrtTaskRunner *runner, void *data) { HwfContainer *container = HWF_CONTAINER(data); HrtTask *task; while ((task = hrt_task_runner_pop_completed(container->runner)) != NULL) { g_object_unref(task); } }
static void on_tasks_completed(HrtTaskRunner *runner, void *data) { TestFixture *fixture = data; HrtTask *task; while ((task = hrt_task_runner_pop_completed(fixture->runner)) != NULL) { g_object_unref(task); fixture->tasks_completed_count += 1; if (fixture->tasks_completed_count == fixture->tasks_started_count) { g_main_loop_quit(fixture->loop); } } }