static void ide_autotools_build_system_get_build_flags_async (IdeBuildSystem *build_system, IdeFile *file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeAutotoolsBuildSystem *self = (IdeAutotoolsBuildSystem *)build_system; g_autoptr(GTask) task = NULL; GFile *gfile; g_assert (IDE_IS_AUTOTOOLS_BUILD_SYSTEM (self)); g_assert (IDE_IS_FILE (file)); EGG_COUNTER_INC (build_flags); gfile = ide_file_get_file (file); task = g_task_new (self, cancellable, callback, user_data); g_task_set_task_data (task, g_object_ref (gfile), g_object_unref); ide_autotools_build_system_get_makecache_async (self, cancellable, ide_autotools_build_system__makecache_cb, g_object_ref (task)); }
static void ide_git_buffer_change_monitor_init (IdeGitBufferChangeMonitor *self) { EGG_COUNTER_INC (instances); self->signal_group = egg_signal_group_new (IDE_TYPE_BUFFER); egg_signal_group_connect_object (self->signal_group, "insert-text", G_CALLBACK (ide_git_buffer_change_monitor__buffer_insert_text_after_cb), self, G_CONNECT_SWAPPED | G_CONNECT_AFTER); egg_signal_group_connect_object (self->signal_group, "delete-range", G_CALLBACK (ide_git_buffer_change_monitor__buffer_delete_range_cb), self, G_CONNECT_SWAPPED); egg_signal_group_connect_object (self->signal_group, "delete-range", G_CALLBACK (ide_git_buffer_change_monitor__buffer_delete_range_after_cb), self, G_CONNECT_SWAPPED | G_CONNECT_AFTER); egg_signal_group_connect_object (self->signal_group, "changed", G_CALLBACK (ide_git_buffer_change_monitor__buffer_changed_after_cb), self, G_CONNECT_SWAPPED | G_CONNECT_AFTER); self->vcs_signal_group = egg_signal_group_new (IDE_TYPE_GIT_VCS); egg_signal_group_connect_object (self->vcs_signal_group, "reloaded", G_CALLBACK (ide_git_buffer_change_monitor__vcs_reloaded_cb), self, G_CONNECT_SWAPPED); }
void egg_task_cache_init (EggTaskCache *self) { EGG_COUNTER_INC (instances); self->evict_heap = egg_heap_new (sizeof (gpointer), cache_item_compare_evict_at); }
/** * ide_thread_pool_push_task: * @kind: The task kind. * @task: A #GTask to execute. * @func: (scope async): The thread worker to execute for @task. * * This pushes a task to be executed on a worker thread based on the task kind as denoted by * @kind. Some tasks will be placed on special work queues or throttled based on proirity. */ void ide_thread_pool_push_task (IdeThreadPoolKind kind, GTask *task, GTaskThreadFunc func) { GThreadPool *pool; IDE_ENTRY; g_return_if_fail (kind >= 0); g_return_if_fail (kind < IDE_THREAD_POOL_LAST); g_return_if_fail (G_IS_TASK (task)); g_return_if_fail (func != NULL); EGG_COUNTER_INC (TotalTasks); pool = ide_thread_pool_get_pool (kind); if (pool != NULL) { WorkItem *work_item; work_item = g_slice_new0 (WorkItem); work_item->type = TYPE_TASK; work_item->task.task = g_object_ref (task); work_item->task.func = func; EGG_COUNTER_INC (QueuedTasks); g_thread_pool_push (pool, work_item, NULL); } else { g_task_run_in_thread (task, func); } IDE_EXIT; }
/** * ide_thread_pool_push: * @kind: the threadpool kind to use. * @func: (scope async) (closure func_data): A function to call in the worker thread. * @func_data: user data for @func. * * Runs the callback on the thread pool thread. */ void ide_thread_pool_push (IdeThreadPoolKind kind, IdeThreadFunc func, gpointer func_data) { GThreadPool *pool; IDE_ENTRY; g_return_if_fail (kind >= 0); g_return_if_fail (kind < IDE_THREAD_POOL_LAST); g_return_if_fail (func != NULL); EGG_COUNTER_INC (TotalTasks); pool = ide_thread_pool_get_pool (kind); if (pool != NULL) { WorkItem *work_item; work_item = g_slice_new0 (WorkItem); work_item->type = TYPE_FUNC; work_item->func.callback = func; work_item->func.data = func_data; EGG_COUNTER_INC (QueuedTasks); g_thread_pool_push (pool, work_item, NULL); } else { g_critical ("No such thread pool %02x", kind); } IDE_EXIT; }
static void ide_file_settings_init (IdeFileSettings *self) { IdeFileSettingsPrivate *priv = ide_file_settings_get_instance_private (self); EGG_COUNTER_INC (instances); priv->indent_style = IDE_INDENT_STYLE_SPACES; priv->indent_width = -1; priv->insert_trailing_newline = TRUE; priv->newline_type = GTK_SOURCE_NEWLINE_TYPE_LF; priv->right_margin_position = 80; priv->tab_width = 8; priv->trim_trailing_whitespace = TRUE; }
/** * egg_task_cache_peek: * @self: An #EggTaskCache * @key: The key for the cache * * Peeks to see @key is contained in the cache and returns the * matching #GObject if it does. * * The reference count of the resulting #GObject is not incremented. * For that reason, it is important to remember that this function * may only be called from the main thread. * * Returns: (type GObject.Object) (nullable) (transfer none): A #GObject or * %NULL if the key was not found in the cache. */ gpointer egg_task_cache_peek (EggTaskCache *self, gconstpointer key) { CacheItem *item; g_return_val_if_fail (EGG_IS_TASK_CACHE (self), NULL); if ((item = g_hash_table_lookup (self->cache, key))) { EGG_COUNTER_INC (hits); return item->value; } return NULL; }
IdeDiagnostic * _ide_diagnostic_new (IdeDiagnosticSeverity severity, const gchar *text, IdeSourceLocation *location) { IdeDiagnostic *ret; ret = g_new0 (IdeDiagnostic, 1); ret->ref_count = 1; ret->severity = severity; ret->text = g_strdup (text); ret->location = location ? ide_source_location_ref (location) : NULL; EGG_COUNTER_INC (instances); return ret; }
static void egg_task_cache_populate (EggTaskCache *self, gconstpointer key, gpointer value) { CacheItem *item; g_assert (EGG_IS_TASK_CACHE (self)); item = cache_item_new (self, key, value); if (g_hash_table_contains (self->cache, key)) egg_task_cache_evict (self, key); g_hash_table_insert (self->cache, item->key, item); egg_heap_insert_val (self->evict_heap, item); EGG_COUNTER_INC (cached); if (self->evict_source != NULL) evict_source_rearm (self->evict_source); }
void egg_task_cache_get_async (EggTaskCache *self, gconstpointer key, gboolean force_update, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; GPtrArray *queued; gpointer ret; g_return_if_fail (EGG_IS_TASK_CACHE (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); /* * If we have the answer, return it now. */ if (!force_update && (ret = egg_task_cache_peek (self, key))) { g_task_return_pointer (task, self->value_copy_func (ret), self->value_destroy_func); return; } EGG_COUNTER_INC (misses); /* * Always queue the request. If we need to dispatch the worker to * fetch the result, that will happen with another task. */ if (!(queued = g_hash_table_lookup (self->queued, key))) { queued = g_ptr_array_new_with_free_func (g_object_unref); g_hash_table_insert (self->queued, self->key_copy_func ((gpointer)key), queued); } g_ptr_array_add (queued, g_object_ref (task)); EGG_COUNTER_INC (queued); /* * The in_flight hashtable will have a bit set if we have queued * an operation for this key. */ if (!g_hash_table_contains (self->in_flight, key)) { g_autoptr(GTask) fetch_task = NULL; fetch_task = g_task_new (self, cancellable, egg_task_cache_fetch_cb, self->key_copy_func ((gpointer)key)); g_hash_table_insert (self->in_flight, self->key_copy_func ((gpointer)key), GINT_TO_POINTER (TRUE)); self->populate_callback (self, key, g_object_ref (fetch_task), self->populate_callback_data); EGG_COUNTER_INC (in_flight); } }
static void ide_file_init (IdeFile *file) { EGG_COUNTER_INC (instances); }
static void ide_ctags_completion_item_init (IdeCtagsCompletionItem *self) { EGG_COUNTER_INC (instances); }
static void ide_clang_service_parse_worker (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { g_autoptr(IdeClangTranslationUnit) ret = NULL; g_autoptr(IdeHighlightIndex) index = NULL; g_autoptr(IdeFile) file_copy = NULL; IdeClangService *self = source_object; CXTranslationUnit tu = NULL; ParseRequest *request = task_data; IdeContext *context; const gchar * const *argv; GFile *gfile; gsize argc = 0; const gchar *detail_error = NULL; enum CXErrorCode code; GArray *ar = NULL; gsize i; g_assert (G_IS_TASK (task)); g_assert (IDE_IS_CLANG_SERVICE (source_object)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); g_assert (IDE_IS_FILE (request->file)); file_copy = g_object_ref (request->file); ar = g_array_new (FALSE, FALSE, sizeof (struct CXUnsavedFile)); g_array_set_clear_func (ar, clear_unsaved_file); for (i = 0; i < request->unsaved_files->len; i++) { IdeUnsavedFile *iuf = g_ptr_array_index (request->unsaved_files, i); struct CXUnsavedFile uf; GBytes *content; GFile *file; file = ide_unsaved_file_get_file (iuf); content = ide_unsaved_file_get_content (iuf); uf.Filename = g_file_get_path (file); uf.Contents = g_bytes_get_data (content, NULL); uf.Length = g_bytes_get_size (content); g_array_append_val (ar, uf); } argv = (const gchar * const *)request->command_line_args; argc = argv ? g_strv_length (request->command_line_args) : 0; EGG_COUNTER_INC (ParseAttempts); code = clang_parseTranslationUnit2 (request->index, request->source_filename, argv, argc, (struct CXUnsavedFile *)(void *)ar->data, ar->len, request->options, &tu); switch (code) { case CXError_Success: index = ide_clang_service_build_index (self, tu, request); #ifdef IDE_ENABLE_TRACE ide_highlight_index_dump (index); #endif break; case CXError_Failure: detail_error = _("Unknown failure"); break; case CXError_Crashed: detail_error = _("Clang crashed"); break; case CXError_InvalidArguments: detail_error = _("Invalid arguments"); break; case CXError_ASTReadError: detail_error = _("AST read error"); break; default: break; } if (!tu) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, _("Failed to create translation unit: %s"), detail_error ? detail_error : ""); goto cleanup; } context = ide_object_get_context (source_object); gfile = ide_file_get_file (request->file); ret = _ide_clang_translation_unit_new (context, tu, gfile, index, request->sequence); g_task_return_pointer (task, g_object_ref (ret), g_object_unref); cleanup: g_array_unref (ar); }