gint main (gint argc, gchar *argv[]) { IrisTask *task = NULL; gchar *dir = g_get_current_dir (); if (argc > 1) dir = g_strdup (argv [1]); iris_init (); mutex = g_mutex_new (); cond = g_cond_new (); g_mutex_lock (mutex); task = iris_task_new (worker, dir, NULL); iris_task_add_callback (task, callback, NULL, NULL); iris_task_run (task); g_cond_wait (cond, mutex); g_mutex_unlock (mutex); g_free (dir); return 0; }
/** * iris_task_all_of: * @first_task: An #IrisTask * * Creates a new task that will complete when each of the passed * #IrisTask<!-- -->'s complete. * * Return value: the newly created #IrisTask instance. */ IrisTask* iris_task_all_of (GList *tasks) { IrisTask *task; g_return_val_if_fail (tasks != NULL, NULL); task = iris_task_new (); for (; tasks; tasks = tasks->next) iris_task_add_dependency (task, tasks->data); return task; }
/** * iris_task_vall_of: * @first_task: An #IrisTask * * Creates a new task that will complete when each of the passed * #IrisTask<!-- -->'s complete. * * Return value: the newly created #IrisTask instance. */ IrisTask* iris_task_vall_of (IrisTask *first_task, ...) { IrisTask *task; IrisTask *iter; va_list args; if (!first_task) return NULL; task = iris_task_new (); iter = first_task; va_start (args, first_task); while (iter) { if (IRIS_IS_TASK (iter)) iris_task_add_dependency (task, iter); iter = va_arg (args, IrisTask*); } va_end (args); return task; }