void screenshot_build_filename_async (const char *save_dir, const char *screenshot_origin, GAsyncReadyCallback callback, gpointer user_data) { AsyncExistenceJob *job; GTask *task; job = g_slice_new0 (AsyncExistenceJob); job->base_paths[TEST_SAVED_DIR] = sanitize_save_directory (save_dir); job->base_paths[TEST_DEFAULT] = get_default_screenshot_dir (); job->base_paths[TEST_FALLBACK] = get_fallback_screenshot_dir (); job->iteration = 0; job->type = TEST_SAVED_DIR; job->screenshot_origin = g_strdup (screenshot_origin); task = g_task_new (NULL, NULL, callback, user_data); g_task_set_task_data (task, job, (GDestroyNotify) async_existence_job_free); g_task_run_in_thread (task, try_check_file); g_object_unref (task); }
/** * st_texture_cache_load_sliced_image: * @cache: A #StTextureCache * @file: A #GFile * @grid_width: Width in pixels * @grid_height: Height in pixels * @scale: Scale factor of the display * @load_callback: (scope async) (nullable): Function called when the image is loaded, or %NULL * @user_data: Data to pass to the load callback * * This function reads a single image file which contains multiple images internally. * The image file will be divided using @grid_width and @grid_height; * note that the dimensions of the image loaded from @path * should be a multiple of the specified grid dimensions. * * Returns: (transfer none): A new #ClutterActor */ ClutterActor * st_texture_cache_load_sliced_image (StTextureCache *cache, GFile *file, gint grid_width, gint grid_height, gint scale, GFunc load_callback, gpointer user_data) { AsyncImageData *data; GTask *result; ClutterActor *actor = clutter_actor_new (); data = g_new0 (AsyncImageData, 1); data->grid_width = grid_width; data->grid_height = grid_height; data->scale_factor = scale; data->gfile = g_object_ref (file); data->actor = actor; data->load_callback = load_callback; data->load_callback_data = user_data; g_object_ref (G_OBJECT (actor)); result = g_task_new (cache, NULL, on_sliced_image_loaded, data); g_task_set_task_data (result, data, on_data_destroy); g_task_run_in_thread (result, load_sliced_image); g_object_unref (result); return actor; }
void abrt_p2_task_start(AbrtP2Task *task, GVariant *options, GError **error) { if ( task->pv->p2t_status != ABRT_P2_TASK_STATUS_NEW && task->pv->p2t_status != ABRT_P2_TASK_STATUS_STOPPED) { g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Cannot start task that is not new or stopped"); return; } ABRT_P2_TASK_VIRTUAL_START(task, options, error); if (*error != NULL) return; task->pv->p2t_cancellable = g_cancellable_new(); GTask *gtask = g_task_new(task, task->pv->p2t_cancellable, abrt_p2_task_finish_gtask, NULL); g_task_run_in_thread(gtask, abrt_p2_task_thread); abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_RUNNING); g_object_unref(gtask); }
static void watch_smartcards_from_driver_async (GsdSmartcardManager *self, SECMODModule *driver, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GsdSmartcardManagerPrivate *priv = self->priv; GTask *task; WatchSmartcardsOperation *operation; operation = g_new0 (WatchSmartcardsOperation, 1); operation->driver = SECMOD_ReferenceModule (driver); operation->smartcards = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) PK11_FreeSlot); task = g_task_new (self, cancellable, callback, user_data); g_task_set_task_data (task, operation, (GDestroyNotify) destroy_watch_smartcards_operation); G_LOCK (gsd_smartcards_watch_tasks); priv->smartcards_watch_tasks = g_list_prepend (priv->smartcards_watch_tasks, task); g_object_weak_ref (G_OBJECT (task), (GWeakNotify) on_smartcards_watch_task_destroyed, self); G_UNLOCK (gsd_smartcards_watch_tasks); g_task_run_in_thread (task, (GTaskThreadFunc) watch_smartcards_from_driver); }
static void save_file_done (GObject *source, GAsyncResult *result, gpointer data) { g_autoptr(Request) request = data; guint response; GVariant *options; g_autoptr(GError) error = NULL; g_autoptr(GTask) task = NULL; if (!xdp_impl_file_chooser_call_save_file_finish (XDP_IMPL_FILE_CHOOSER (source), &response, &options, result, &error)) { g_warning ("Backend call failed: %s", error->message); } g_object_set_data (G_OBJECT (request), "response", GINT_TO_POINTER (response)); if (options) g_object_set_data_full (G_OBJECT (request), "options", g_variant_ref (options), (GDestroyNotify)g_variant_unref); task = g_task_new (NULL, NULL, NULL, NULL); g_task_set_task_data (task, g_object_ref (request), g_object_unref); g_task_run_in_thread (task, send_response_in_thread_func); }
/** * meta_background_image_cache_load: * @cache: a #MetaBackgroundImageCache * @file: #GFile to load * * Loads an image to use as a background, or returns a reference to an * image that is already in the process of loading or loaded. In either * case, what is returned is a #MetaBackgroundImage which can be derefenced * to get a #CoglTexture. If meta_background_image_is_loaded() returns %TRUE, * the background is loaded, otherwise the MetaBackgroundImage::loaded * signal will be emitted exactly once. The 'loaded' state means that the * loading process finished, whether it succeeded or failed. * * Return value: (transfer full): a #MetaBackgroundImage to dereference to get the loaded texture */ MetaBackgroundImage * meta_background_image_cache_load (MetaBackgroundImageCache *cache, GFile *file) { MetaBackgroundImage *image; GTask *task; g_return_val_if_fail (META_IS_BACKGROUND_IMAGE_CACHE (cache), NULL); g_return_val_if_fail (file != NULL, NULL); image = g_hash_table_lookup (cache->images, file); if (image != NULL) return g_object_ref (image); image = g_object_new (META_TYPE_BACKGROUND_IMAGE, NULL); image->cache = cache; image->in_cache = TRUE; image->file = g_object_ref (file); g_hash_table_insert (cache->images, image->file, image); task = g_task_new (image, NULL, file_loaded, NULL); g_task_run_in_thread (task, (GTaskThreadFunc) load_file); g_object_unref (task); return image; }
void ide_language_defaults_init_async (GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; IDE_ENTRY; g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (NULL, cancellable, callback, user_data); G_LOCK (lock); if (initialized) { g_task_return_boolean (task, TRUE); } else if (initializing) { tasks = g_list_prepend (tasks, g_object_ref (task)); } else { initializing = TRUE; g_task_run_in_thread (task, ide_language_defaults_init_worker); } G_UNLOCK (lock); IDE_EXIT; }
/* This function is added as a very low priority idle function to start the thread to create any needed thumbnails. It is added with a very low priority so that it doesn't delay showing the directory in the icon/list views. We want to show the files in the directory as quickly as possible. */ static gboolean thumbnail_thread_starter_cb (gpointer data) { GTask *task; /* Don't do this in thread, since g_object_ref is not threadsafe */ if (thumbnail_factory == NULL) { thumbnail_factory = get_thumbnail_factory (); } #ifdef DEBUG_THUMBNAILS g_message ("(Main Thread) Creating thumbnails thread\n"); #endif /* We set a flag to indicate the thread is running, so we don't create a new one. We don't need to lock a mutex here, as the thumbnail thread isn't running yet. And we know we won't create the thread twice, as we also check thumbnail_thread_starter_id before scheduling this idle function. */ thumbnail_thread_is_running = TRUE; task = g_task_new (NULL, NULL, NULL, NULL); g_task_run_in_thread (task, thumbnail_thread_func); thumbnail_thread_starter_id = 0; g_object_unref (task); return FALSE; }
/** * json_parser_load_from_stream_async: * @parser: a #JsonParser * @stream: a #GInputStream * @cancellable: (allow-none): a #GCancellable, or %NULL * @callback: a #GAsyncReadyCallback to call when the request is satisfied * @user_data: the data to pass to @callback * * Asynchronously reads the contents of @stream. * * For more details, see json_parser_load_from_stream() which is the * synchronous version of this call. * * When the operation is finished, @callback will be called. You should * then call json_parser_load_from_stream_finish() to get the result * of the operation. * * Since: 0.12 */ void json_parser_load_from_stream_async (JsonParser *parser, GInputStream *stream, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { LoadData *data; GTask *task; g_return_if_fail (JSON_IS_PARSER (parser)); g_return_if_fail (G_IS_INPUT_STREAM (stream)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); data = g_new (LoadData, 1); data->stream = g_object_ref (stream); data->content = g_byte_array_new (); data->pos = 0; task = g_task_new (parser, cancellable, callback, user_data); g_task_set_task_data (task, data, load_data_free); g_task_run_in_thread (task, read_from_stream); g_object_unref (task); }
static void save_snapshot_get_message_cb (EMsgComposer *composer, GAsyncResult *result, GSimpleAsyncResult *simple) { SaveContext *context; CamelMimeMessage *message; GTask *task; GError *local_error = NULL; context = g_simple_async_result_get_op_res_gpointer (simple); message = e_msg_composer_get_message_draft_finish ( composer, result, &local_error); if (local_error != NULL) { g_warn_if_fail (message == NULL); g_simple_async_result_take_error (simple, local_error); g_simple_async_result_complete (simple); g_object_unref (simple); return; } g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); task = g_task_new (message, context->cancellable, (GAsyncReadyCallback) save_snapshot_splice_cb, simple); g_task_set_task_data (task, g_object_ref (context->output_stream), g_object_unref); g_task_run_in_thread (task, write_message_to_stream_thread); g_object_unref (task); g_object_unref (message); }
/** * ide_compile_commands_load_async: * @self: An #IdeCompileCommands * @file: a #GFile * @cancellable: (nullable): a #GCancellable, or %NULL * @callback: the callback for the async operation * @user_data: user data for @callback * * Asynchronously loads the contents of the requested @file and parses * the JSON command database contained within. * * You may only call this function once on an #IdeCompileCommands object. * If there is a failure, you must create a new #IdeCompileCommands instance * instead of calling this function again. * * See also: ide_compile_commands_load_finish() * * Since: 3.28 */ void ide_compile_commands_load_async (IdeCompileCommands *self, GFile *file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; IDE_ENTRY; g_return_if_fail (IDE_IS_COMPILE_COMMANDS (self)); g_return_if_fail (self->has_loaded == FALSE); g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); self->has_loaded = TRUE; task = g_task_new (self, cancellable, callback, user_data); g_task_set_priority (task, G_PRIORITY_LOW); g_task_set_source_tag (task, ide_compile_commands_load_async); g_task_set_task_data (task, g_object_ref (file), g_object_unref); g_task_run_in_thread (task, ide_compile_commands_load_worker); IDE_EXIT; }
/** * g_io_scheduler_push_job: * @job_func: a #GIOSchedulerJobFunc. * @user_data: data to pass to @job_func * @notify: (allow-none): a #GDestroyNotify for @user_data, or %NULL * @io_priority: the <link linkend="io-priority">I/O priority</link> * of the request. * @cancellable: optional #GCancellable object, %NULL to ignore. * * Schedules the I/O job to run in another thread. * * @notify will be called on @user_data after @job_func has returned, * regardless whether the job was cancelled or has run to completion. * * If @cancellable is not %NULL, it can be used to cancel the I/O job * by calling g_cancellable_cancel() or by calling * g_io_scheduler_cancel_all_jobs(). * * Deprecated: use #GThreadPool or g_task_run_in_thread() **/ void g_io_scheduler_push_job (GIOSchedulerJobFunc job_func, gpointer user_data, GDestroyNotify notify, gint io_priority, GCancellable *cancellable) { GIOSchedulerJob *job; GTask *task; g_return_if_fail (job_func != NULL); job = g_slice_new0 (GIOSchedulerJob); job->job_func = job_func; job->data = user_data; job->destroy_notify = notify; if (cancellable) job->cancellable = g_object_ref (cancellable); job->context = g_main_context_ref_thread_default (); G_LOCK (active_jobs); active_jobs = g_list_prepend (active_jobs, job); job->active_link = active_jobs; G_UNLOCK (active_jobs); task = g_task_new (NULL, cancellable, NULL, NULL); g_task_set_task_data (task, job, (GDestroyNotify)g_io_job_free); g_task_set_priority (task, io_priority); g_task_run_in_thread (task, io_job_thread); g_object_unref (task); }
/** * gdata_access_handler_get_rules_async: * @self: a #GDataAccessHandler * @service: a #GDataService * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @progress_callback: (allow-none) (closure progress_user_data): a #GDataQueryProgressCallback to call when a rule is loaded, or %NULL * @progress_user_data: (closure): data to pass to the @progress_callback function * @destroy_progress_user_data: (allow-none): the function to call when @progress_callback will not be called any more, or %NULL. This function will be * called with @progress_user_data as a parameter and can be used to free any memory allocated for it. * @callback: a #GAsyncReadyCallback to call when the query is finished * @user_data: (closure): data to pass to the @callback function * * Retrieves a #GDataFeed containing all the access rules which apply to the given #GDataAccessHandler. Only the owner of a #GDataAccessHandler may * view its rule feed. @self and @service are both reffed when this function is called, so can safely be unreffed after this function returns. * * For more details, see gdata_access_handler_get_rules(), which is the synchronous version of this function, and gdata_service_query_async(), which * is the base asynchronous query function. * * When the operation is finished, @callback will be called. You can then call gdata_service_query_finish() * to get the results of the operation. * * Since: 0.9.1 */ void gdata_access_handler_get_rules_async (GDataAccessHandler *self, GDataService *service, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GDestroyNotify destroy_progress_user_data, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; GetRulesAsyncData *data; g_return_if_fail (GDATA_IS_ACCESS_HANDLER (self)); g_return_if_fail (GDATA_IS_SERVICE (service)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); data = g_slice_new (GetRulesAsyncData); data->service = g_object_ref (service); data->progress_callback = progress_callback; data->progress_user_data = progress_user_data; data->destroy_progress_user_data = destroy_progress_user_data; task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, gdata_service_query_async); g_task_set_task_data (task, g_steal_pointer (&data), (GDestroyNotify) get_rules_async_data_free); g_task_run_in_thread (task, get_rules_thread); }
void cd_sensor_get_sample_async (CdSensor *sensor, CdSensorCap cap, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); task = g_task_new (sensor, cancellable, callback, user_data); if (cap == CD_SENSOR_CAP_AMBIENT) { g_task_run_in_thread (task, cd_sensor_munki_get_ambient_thread_cb); } else if (cap == CD_SENSOR_CAP_LCD || cap == CD_SENSOR_CAP_LED || cap == CD_SENSOR_CAP_CRT) { g_task_run_in_thread (task, cd_sensor_munki_sample_thread_cb); } }
/** * ostree_sysroot_lock_async: * @self: Self * @cancellable: Cancellable * @callback: Callback * @user_data: User data * * An asynchronous version of ostree_sysroot_lock(). */ void ostree_sysroot_lock_async (OstreeSysroot *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = g_task_new (self, cancellable, callback, user_data); g_task_run_in_thread (task, lock_in_thread); }
/** * gnlp_get_available_languages: * @cancellable: (nullable): a #GCancellable * @callback: (scope async): a #GAsyncReadyCallback to call when the initialization is done * @user_data: (closure): data to pass to the callback function * * Starts retrieving the list of languages * * Since: 0.1.0 */ void gnlp_get_available_languages (GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (NULL, cancellable, callback, user_data); g_task_run_in_thread (task, get_languages_in_thread_cb); }
static void populate_search_providers (CcSearchPanel *self) { GTask *task; self->priv->load_cancellable = g_cancellable_new (); task = g_task_new (self, self->priv->load_cancellable, search_providers_discover_ready, self); g_task_run_in_thread (task, search_providers_discover_thread); g_object_unref (task); }
JS_EXPORT_API void installer_start_install() { g_message("[%s]\n", __func__); if (mkfs_pending_list != NULL) { GTask* task = g_task_new(NULL, NULL, start_prepare_conf, NULL); g_task_run_in_thread(task, do_mkfs); } else { start_prepare_conf(); } }
static void extract_gibest_hash_async (ResolveData *resolve_data, GFile *file, GCancellable *cancellable) { GTask *task; task = g_task_new (G_OBJECT (file), cancellable, extract_gibest_hash_done, resolve_data); g_task_run_in_thread (task, extract_gibest_hash); }
void cd_sensor_unlock_async (CdSensor *sensor, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); task = g_task_new (sensor, cancellable, callback, user_data); g_task_run_in_thread (task, cd_sensor_unlock_thread_cb); }
static void load_apps_async (CcNotificationsPanel *panel) { GTask *task; panel->apps_load_cancellable = g_cancellable_new (); task = g_task_new (panel, panel->apps_load_cancellable, NULL, NULL); g_task_run_in_thread (task, load_apps_thread); g_object_unref (task); }
static void lvm_update (UDisksDaemon *daemon) { /* the callback (lvm_update_vgs) is called in the default main loop (context) */ GTask *task = g_task_new (daemon, NULL /* cancellable */, lvm_update_vgs, NULL /* callback_data */); /* holds a reference to 'task' until it is finished */ g_task_run_in_thread (task, (GTaskThreadFunc) vgs_task_func); g_object_unref (task); }
static void http_cal_schedule_begin_retrieval (ECalBackendHttp *cbhttp) { GTask *task; task = g_task_new (cbhttp, NULL, NULL, NULL); g_task_run_in_thread (task, begin_retrieval_cb); g_object_unref (task); }
void pp_cups_get_dests_async (PpCups *cups, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (cups, cancellable, callback, user_data); g_task_run_in_thread (task, (GTaskThreadFunc) _pp_cups_get_dests_thread); g_object_unref (task); }
static void soup_request_file_send_async (SoupRequest *request, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (request, cancellable, callback, user_data); g_task_run_in_thread (task, soup_request_file_send_async_thread); g_object_unref (task); }
/** * tracker_miner_manager_index_file_async: * @manager: a #TrackerMinerManager * @file: a URL valid in GIO of a file to give to the miner for processing * @cancellable: (allow-none): a #GCancellable, or %NULL * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied * @user_data: the data to pass to the callback function * * Tells the filesystem miner to start indexing the @file. Once the message has been sent, * @callback will be called. You can then call tracker_miner_manager_index_file_finish() * to get the result. * * Since: 0.16 **/ void tracker_miner_manager_index_file_async (TrackerMinerManager *manager, GFile *file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = g_task_new (manager, cancellable, callback, user_data); g_task_set_task_data (task, g_object_ref (file), (GDestroyNotify) g_object_unref); g_task_run_in_thread (task, miner_manager_index_file_thread); g_object_unref (task); }
static void ide_mingw_device_provider_constructed (GObject *object) { IdeMingwDeviceProvider *self = (IdeMingwDeviceProvider *)object; g_autoptr(GTask) task = NULL; g_assert (IDE_IS_MINGW_DEVICE_PROVIDER (self)); ide_object_hold (IDE_OBJECT (self)); task = g_task_new (self, NULL, load_cb, NULL); g_task_run_in_thread (task, ide_mingw_device_provider_discover_worker); }
static void watch_smartcards_async (GsdSmartcardManager *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (self, cancellable, callback, user_data); g_task_run_in_thread (task, (GTaskThreadFunc) watch_smartcards); }
void pp_cups_connection_test_async (PpCups *cups, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (cups, NULL, callback, user_data); g_task_run_in_thread (task, connection_test_thread); g_object_unref (task); }
void hev_filebox_uploader_handle_async (HevFileboxUploader *self, GObject *scgi_task, GAsyncReadyCallback callback, gpointer user_data) { GTask *task = NULL; g_debug ("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); task = g_task_new (self, NULL, callback, user_data); g_task_set_task_data (task, g_object_ref (scgi_task), (GDestroyNotify) g_object_unref); g_task_run_in_thread (task, filebox_uploader_handle_task_handler); g_object_unref (task); }