static GList * lookup_records (GResolver *resolver, const gchar *rrname, GResolverRecordType record_type, GCancellable *cancellable, GError **error) { GTask *task; GList *records; LookupRecordsData *lrd; task = g_task_new (resolver, cancellable, NULL, NULL); g_task_set_source_tag (task, lookup_records); 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_sync (task, do_lookup_records); records = g_task_propagate_pointer (task, error); g_object_unref (task); return records; }
/** * ide_compile_commands_load: * @self: An #IdeCompileCommands * @file: a #GFile * @cancellable: (nullable): a #GCancellable, or %NULL * @error: A location for a #GError, or %NULL * * Synchronously 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_async() * * Returns: %TRUE if successful; otherwise %FALSE and @error is set. * * Since: 3.28 */ gboolean ide_compile_commands_load (IdeCompileCommands *self, GFile *file, GCancellable *cancellable, GError **error) { g_autoptr(GTask) task = NULL; gboolean ret; IDE_ENTRY; g_return_val_if_fail (IDE_IS_COMPILE_COMMANDS (self), FALSE); g_return_val_if_fail (self->has_loaded == FALSE, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE); self->has_loaded = TRUE; task = g_task_new (self, cancellable, NULL, NULL); g_task_set_priority (task, G_PRIORITY_LOW); g_task_set_source_tag (task, ide_compile_commands_load); g_task_set_task_data (task, g_object_ref (file), g_object_unref); g_task_run_in_thread_sync (task, ide_compile_commands_load_worker); ret = g_task_propagate_boolean (task, error); IDE_RETURN (ret); }
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_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 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_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 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 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; }