void gdav_propfind (SoupSession *session, SoupURI *uri, GDavPropFindType type, GDavPropertySet *prop, GDavDepth depth, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; SoupRequestHTTP *request; AsyncContext *async_context; GError *local_error = NULL; g_return_if_fail (SOUP_IS_SESSION (session)); g_return_if_fail (uri != NULL); async_context = g_slice_new0 (AsyncContext); task = g_task_new (session, cancellable, callback, user_data); g_task_set_source_tag (task, gdav_propfind); g_task_set_task_data ( task, async_context, (GDestroyNotify) async_context_free); request = gdav_request_propfind_uri ( session, uri, type, prop, depth, &local_error); /* Sanity check */ g_warn_if_fail ( ((request != NULL) && (local_error == NULL)) || ((request == NULL) && (local_error != NULL))); if (request != NULL) { async_context->message = soup_request_http_get_message (request); gdav_request_send ( request, cancellable, gdav_propfind_request_cb, g_object_ref (task)); g_object_unref (request); } else { g_task_return_error (task, local_error); } g_object_unref (task); }
static void ide_langserv_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver, GFile *file, IdeBuffer *buffer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeLangservSymbolResolver *self = (IdeLangservSymbolResolver *)resolver; IdeLangservSymbolResolverPrivate *priv = ide_langserv_symbol_resolver_get_instance_private (self); g_autoptr(GTask) task = NULL; g_autoptr(GVariant) params = NULL; g_autofree gchar *uri = NULL; IDE_ENTRY; g_assert (IDE_IS_LANGSERV_SYMBOL_RESOLVER (self)); g_assert (G_IS_FILE (file)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_langserv_symbol_resolver_get_symbol_tree_async); if (priv->client == NULL) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_CONNECTED, "Cannot query language server, not connected"); IDE_EXIT; } uri = g_file_get_uri (file); params = JSONRPC_MESSAGE_NEW ( "textDocument", "{", "uri", JSONRPC_MESSAGE_PUT_STRING (uri), "}" ); ide_langserv_client_call_async (priv->client, "textDocument/documentSymbol", g_steal_pointer (¶ms), cancellable, ide_langserv_symbol_resolver_document_symbol_cb, g_steal_pointer (&task)); IDE_EXIT; }
static void photos_base_item_create_thumbnail_async (PhotosBaseItem *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (self, cancellable, callback, user_data); g_task_set_check_cancellable (task, TRUE); g_task_set_source_tag (task, photos_base_item_create_thumbnail_async); g_thread_pool_push (create_thumbnail_pool, g_object_ref (task), NULL); g_object_unref (task); }
static void g_tls_connection_base_close_async (GIOStream *stream, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (stream, cancellable, callback, user_data); g_task_set_source_tag (task, g_tls_connection_base_close_async); g_task_set_priority (task, io_priority); g_task_run_in_thread (task, close_thread); g_object_unref (task); }
static void photos_thumbnailer_generate_thumbnail_async (PhotosThumbnailer *self, const gchar *uri, const gchar *mime_type, const gchar *orientation, gint64 original_height, gint64 original_width, const gchar *const *pipeline_uris, const gchar *thumbnail_path, gint thumbnail_size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr (GFile) file = NULL; g_autoptr (GTask) task = NULL; GQuark orientation_quark; g_autoptr (GeglNode) graph = NULL; PhotosThumbnailerGenerateData *data; g_return_if_fail (PHOTOS_IS_THUMBNAILER (self)); g_return_if_fail (uri != NULL && uri[0] != '\0'); g_return_if_fail (mime_type != NULL && mime_type[0] != '\0'); g_return_if_fail (orientation != NULL && orientation[0] != '\0'); g_return_if_fail (thumbnail_path != NULL && thumbnail_path[0] != '\0'); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); file = g_file_new_for_uri (uri); orientation_quark = g_quark_from_string (orientation); graph = gegl_node_new (); data = photos_thumbnailer_generate_data_new (file, orientation_quark, original_height, original_width, thumbnail_path, thumbnail_size, graph); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, photos_thumbnailer_generate_thumbnail_async); g_task_set_task_data (task, data, (GDestroyNotify) photos_thumbnailer_generate_data_free); photos_pipeline_new_async (graph, pipeline_uris, cancellable, photos_thumbnailer_generate_thumbnail_pipeline, g_object_ref (task)); }
static void lookup_by_address_async (GResolver *resolver, GInetAddress *address, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (resolver, cancellable, callback, user_data); g_task_set_source_tag (task, lookup_by_address_async); g_task_set_task_data (task, g_object_ref (address), g_object_unref); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, do_lookup_by_address); g_object_unref (task); }
static void g_libproxy_resolver_lookup_async (GProxyResolver *resolver, const gchar *uri, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (resolver, cancellable, callback, user_data); g_task_set_source_tag (task, g_libproxy_resolver_lookup_async); g_task_set_task_data (task, g_strdup (uri), g_free); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, get_libproxy_proxies); g_object_unref (task); }
static void lookup_by_name_async (GResolver *resolver, const gchar *hostname, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; task = g_task_new (resolver, cancellable, callback, user_data); g_task_set_source_tag (task, lookup_by_name_async); g_task_set_task_data (task, g_strdup (hostname), g_free); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, do_lookup_by_name); g_object_unref (task); }
void g_vfs_dns_sd_resolver_resolve (GVfsDnsSdResolver *resolver, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { ResolveData *data; GTask *task; g_return_if_fail (G_VFS_IS_DNS_SD_RESOLVER (resolver)); task = g_task_new (resolver, cancellable, callback, user_data); g_task_set_source_tag (task, g_vfs_dns_sd_resolver_resolve); if (resolver->service_type == NULL) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, _("Error initializing Avahi resolver")); g_object_unref (task); goto out; } if (resolver->is_resolved) { g_task_return_boolean (task, TRUE); g_object_unref (task); goto out; } ensure_avahi_resolver (resolver); data = g_new0 (ResolveData, 1); data->resolver = resolver; data->timeout_id = g_timeout_add (resolver->timeout_msec, (GSourceFunc) service_resolver_timed_out, task); g_task_set_task_data (task, data, (GDestroyNotify) resolve_data_free); g_signal_connect (resolver, "changed", (GCallback) service_resolver_changed, task); out: ; }
static void g_loadable_icon_real_load_async (GLoadableIcon *icon, int size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; LoadData *data; task = g_task_new (icon, cancellable, callback, user_data); g_task_set_source_tag (task, g_loadable_icon_real_load_async); data = g_new0 (LoadData, 1); g_task_set_task_data (task, data, (GDestroyNotify) load_data_free); g_task_run_in_thread (task, load_async_thread); g_object_unref (task); }
static void parse_xml_async (DspyIntrospectionModel *self, GBytes *bytes, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_assert (DSPY_IS_INTROSPECTION_MODEL (self)); g_assert (bytes != NULL); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, parse_xml_async); g_task_set_task_data (task, g_bytes_ref (bytes), (GDestroyNotify) g_bytes_unref); g_task_run_in_thread (task, parse_xml_worker); }
void ide_application_open_async (IdeApplication *self, GFile **files, gint n_files, const gchar *hint, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_autoptr(GPtrArray) ar = NULL; IdeApplicationOpen *state; guint i; g_return_if_fail (IDE_IS_APPLICATION (self)); g_return_if_fail (!n_files || files != NULL); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_application_open_async); g_task_set_check_cancellable (task, FALSE); /* * We have to open each file one at a time so that we don't race to * open the same containing project multiple times. */ ar = g_ptr_array_new_with_free_func (g_object_unref); for (i = 0; i < n_files; i++) { GFile *file = files [i]; if (!maybe_open_with_existing_workspace (self, file, hint, cancellable)) g_ptr_array_add (ar, g_object_ref (file)); } state = g_slice_new0 (IdeApplicationOpen); state->hint = g_strdup (hint); state->files = g_steal_pointer (&ar); g_task_set_task_data (task, state, ide_application_open_free); ide_application_open_tick (task); }
static gchar * lookup_by_address (GResolver *resolver, GInetAddress *address, GCancellable *cancellable, GError **error) { GTask *task; gchar *name; task = g_task_new (resolver, cancellable, NULL, NULL); g_task_set_source_tag (task, lookup_by_address); g_task_set_task_data (task, g_object_ref (address), g_object_unref); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread_sync (task, do_lookup_by_address); name = g_task_propagate_pointer (task, error); g_object_unref (task); return name; }
static gboolean do_implicit_handshake (GTlsConnectionBase *tls, gboolean blocking, GCancellable *cancellable, GError **error) { /* We have op_mutex */ tls->implicit_handshake = g_task_new (tls, cancellable, implicit_handshake_completed, NULL); g_task_set_source_tag (tls->implicit_handshake, do_implicit_handshake); if (blocking) { GError *my_error = NULL; gboolean success; g_mutex_unlock (&tls->op_mutex); g_task_run_in_thread_sync (tls->implicit_handshake, handshake_thread); success = finish_handshake (tls, tls->implicit_handshake, &my_error); g_clear_object (&tls->implicit_handshake); yield_op (tls, G_TLS_CONNECTION_BASE_OP_HANDSHAKE, G_TLS_CONNECTION_BASE_OK); g_mutex_lock (&tls->op_mutex); if (my_error) g_propagate_error (error, my_error); return success; } else { g_task_run_in_thread (tls->implicit_handshake, handshake_thread); g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, _("Operation would block")); return FALSE; } }
static GList * lookup_by_name (GResolver *resolver, const gchar *hostname, GCancellable *cancellable, GError **error) { GTask *task; GList *addresses; task = g_task_new (resolver, cancellable, NULL, NULL); g_task_set_source_tag (task, lookup_by_name); g_task_set_task_data (task, g_strdup (hostname), g_free); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread_sync (task, do_lookup_by_name); addresses = g_task_propagate_pointer (task, error); g_object_unref (task); return addresses; }
static void ide_git_vcs_list_status_async (IdeVcs *vcs, GFile *directory_or_file, gboolean include_descendants, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeGitVcs *self = (IdeGitVcs *)vcs; g_autoptr(GTask) task = NULL; ListStatus *state; IDE_ENTRY; g_return_if_fail (IDE_IS_GIT_VCS (self)); g_return_if_fail (!directory_or_file || G_IS_FILE (directory_or_file)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); g_mutex_lock (&self->repository_mutex); state = g_slice_new0 (ListStatus); state->directory_or_file = g_object_ref (directory_or_file); state->repository_location = ggit_repository_get_location (self->repository); state->recursive = !!include_descendants; g_mutex_unlock (&self->repository_mutex); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_git_vcs_list_status_async); g_task_set_priority (task, io_priority); g_task_set_return_on_cancel (task, TRUE); g_task_set_task_data (task, state, list_status_free); if (state->repository_location == NULL) g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "No repository loaded"); else g_task_run_in_thread (task, ide_git_vcs_list_status_worker); IDE_EXIT; }
static void ide_autotools_build_system_get_build_targets_async (IdeBuildSystem *build_system, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeAutotoolsBuildSystem *self = (IdeAutotoolsBuildSystem *)build_system; g_autoptr(GTask) task = NULL; g_assert (IDE_IS_AUTOTOOLS_BUILD_SYSTEM (self)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_autotools_build_system_get_build_targets_async); ide_autotools_build_system_get_makecache_async (self, cancellable, ide_autotools_build_system_get_build_targets_cb, g_object_ref (task)); }
static void g_unix_input_stream_close_async (GInputStream *stream, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; GError *error = NULL; task = g_task_new (stream, cancellable, callback, user_data); g_task_set_source_tag (task, g_unix_input_stream_close_async); g_task_set_priority (task, io_priority); if (g_unix_input_stream_close (stream, cancellable, &error)) g_task_return_boolean (task, TRUE); else g_task_return_error (task, error); g_object_unref (task); }
static void ide_symbol_resolver_real_get_symbol_tree_async (IdeSymbolResolver *self, GFile *file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_assert (IDE_IS_SYMBOL_RESOLVER (self)); g_assert (G_IS_FILE (file)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_symbol_resolver_get_symbol_tree_async); g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symbol tree is not supported on this symbol resolver"); }
static void remove_account (GoaProvider *provider, GoaObject *object, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GoaTelepathyProvider *self = GOA_TELEPATHY_PROVIDER (provider); GTask *task; task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, remove_account); goa_tp_account_linker_remove_tp_account (tp_linker, object, cancellable, remove_account_remove_tp_account_cb, g_object_ref (task)); g_object_unref (task); }
/* Default implementation just calls the synchronous method; this can * be used if the implementation already knows all of its addresses, * and so the synchronous method will never block. */ static void g_socket_address_enumerator_real_next_async (GSocketAddressEnumerator *enumerator, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; GSocketAddress *address; GError *error = NULL; task = g_task_new (enumerator, NULL, callback, user_data); g_task_set_source_tag (task, g_socket_address_enumerator_real_next_async); address = g_socket_address_enumerator_next (enumerator, cancellable, &error); if (error) g_task_return_error (task, error); else g_task_return_pointer (task, address, g_object_unref); g_object_unref (task); }
void photos_glib_file_create_async (GFile *file, GFileCreateFlags flags, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr (GTask) task = NULL; g_autoptr (PhotosGLibFileCreateData) data = NULL; g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); task = g_task_new (file, cancellable, callback, user_data); g_task_set_source_tag (task, photos_glib_file_create_async); data = photos_glib_file_create_data_new (file, flags, io_priority); g_task_set_task_data (task, g_steal_pointer (&data), (GDestroyNotify) photos_glib_file_create_data_free); g_file_create_async (file, flags, io_priority, cancellable, photos_glib_file_create_create, g_object_ref (task)); }
void ide_run_manager_run_async (IdeRunManager *self, IdeBuildTarget *build_target, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_autoptr(GCancellable) local_cancellable = NULL; GError *error = NULL; IDE_ENTRY; g_return_if_fail (IDE_IS_RUN_MANAGER (self)); g_return_if_fail (!build_target || IDE_IS_BUILD_TARGET (build_target)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); if (cancellable == NULL) cancellable = local_cancellable = g_cancellable_new (); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_run_manager_run_async); g_set_object (&self->cancellable, cancellable); if (ide_run_manager_check_busy (self, &error)) { g_task_return_error (task, error); IDE_EXIT; } if (build_target != NULL) ide_run_manager_set_build_target (self, build_target); ide_run_manager_do_install_before_run (self, task); IDE_EXIT; }
/** * gdata_calendar_service_query_events_async: * @self: a #GDataCalendarService * @calendar: a #GDataCalendarCalendar * @query: (allow-none): a #GDataQuery with the query parameters, or %NULL * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @progress_callback: (allow-none) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry 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 * * Queries the service to return a list of events in the given @calendar, which match @query. @self, @calendar and @query are all reffed when this * function is called, so can safely be unreffed after this function returns. * * Get the results of the query using gdata_service_query_finish() in the @callback. * * For more details, see gdata_calendar_service_query_events(), which is the synchronous version of this function, and gdata_service_query_async(), * which is the base asynchronous query function. * * Since: 0.9.1 */ void gdata_calendar_service_query_events_async (GDataCalendarService *self, GDataCalendarCalendar *calendar, GDataQuery *query, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GDestroyNotify destroy_progress_user_data, GAsyncReadyCallback callback, gpointer user_data) { gchar *request_uri; g_return_if_fail (GDATA_IS_CALENDAR_SERVICE (self)); g_return_if_fail (GDATA_IS_CALENDAR_CALENDAR (calendar)); g_return_if_fail (query == NULL || GDATA_IS_QUERY (query)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); /* Ensure we're authenticated first */ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)), get_calendar_authorization_domain ()) == FALSE) { g_autoptr(GTask) task = NULL; task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, gdata_service_query_async); g_task_return_new_error (task, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, "%s", _("You must be authenticated to query your own calendars.")); return; } /* Execute the query. */ request_uri = build_events_uri (calendar); gdata_service_query_async (GDATA_SERVICE (self), get_calendar_authorization_domain (), request_uri, query, GDATA_TYPE_CALENDAR_EVENT, cancellable, progress_callback, progress_user_data, destroy_progress_user_data, callback, user_data); g_free (request_uri); }
void ide_subprocess_wait_check_async (IdeSubprocess *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; IDE_ENTRY; g_return_if_fail (IDE_IS_SUBPROCESS (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_subprocess_wait_check_async); ide_subprocess_wait_async (self, cancellable, ide_subprocess_wait_check_cb, g_steal_pointer (&task)); IDE_EXIT; }
static gboolean g_tls_connection_base_handshake (GTlsConnection *conn, GCancellable *cancellable, GError **error) { GTlsConnectionBase *tls = G_TLS_CONNECTION_BASE (conn); GTask *task; gboolean success; GError *my_error = NULL; task = g_task_new (conn, cancellable, NULL, NULL); g_task_set_source_tag (task, g_tls_connection_base_handshake); g_task_run_in_thread_sync (task, handshake_thread); success = finish_handshake (tls, task, &my_error); g_object_unref (task); yield_op (tls, G_TLS_CONNECTION_BASE_OP_HANDSHAKE, G_TLS_CONNECTION_BASE_OK); if (my_error) g_propagate_error (error, my_error); return success; }
static void lookup_records_async (GResolver *resolver, const char *rrname, GResolverRecordType record_type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; LookupRecordsData *lrd; task = g_task_new (resolver, cancellable, callback, user_data); g_task_set_source_tag (task, lookup_records_async); lrd = g_slice_new (LookupRecordsData); lrd->rrname = g_strdup (rrname); lrd->record_type = record_type; g_task_set_task_data (task, lrd, (GDestroyNotify) free_lookup_records_data); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, do_lookup_records); g_object_unref (task); }
static void ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider, IdeFile *file, IdeBuffer *buffer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeGettextDiagnosticProvider *self = (IdeGettextDiagnosticProvider *)provider; g_autoptr(IdeUnsavedFile) unsaved_file = NULL; IdeGettextDiagnostics *cached; g_autoptr(GTask) task = NULL; g_return_if_fail (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_gettext_diagnostic_provider_diagnose_async); if (NULL != (cached = dzl_task_cache_peek (self->diagnostics_cache, file))) { unsaved_file = get_unsaved_file (self, file); if (unsaved_file == NULL || (cached->sequence >= ide_unsaved_file_get_sequence (unsaved_file))) { g_task_return_pointer (task, g_object_ref (cached), g_object_unref); return; } } dzl_task_cache_get_async (self->diagnostics_cache, file, TRUE, cancellable, get_diagnostics_cb, g_steal_pointer (&task)); }
/** * g_io_scheduler_push_job: * @job_func: a #GIOSchedulerJobFunc. * @user_data: data to pass to @job_func * @notify: (nullable): a #GDestroyNotify for @user_data, or %NULL * @io_priority: the [I/O priority][io-priority] * 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_GNUC_BEGIN_IGNORE_DEPRECATIONS g_task_set_source_tag (task, g_io_scheduler_push_job); G_GNUC_END_IGNORE_DEPRECATIONS 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); }
static void ide_rename_provider_real_rename_async (IdeRenameProvider *self, IdeSourceLocation *location, const gchar *new_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_assert (IDE_IS_RENAME_PROVIDER (self)); g_assert (location != NULL); g_assert (new_name != NULL); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_rename_provider_real_rename_async); g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "%s has not implemented rename_async", G_OBJECT_TYPE_NAME (self)); }