mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof: add SysprofDocument:busy property
This currently only toggles on/off when a callgraph is being generated or the document is being saved. See #94
This commit is contained in:
@ -107,6 +107,8 @@ struct _SysprofDocument
|
|||||||
|
|
||||||
SysprofDocumentSymbols *symbols;
|
SysprofDocumentSymbols *symbols;
|
||||||
|
|
||||||
|
guint busy_count;
|
||||||
|
|
||||||
SysprofCaptureFileHeader header;
|
SysprofCaptureFileHeader header;
|
||||||
guint needs_swap : 1;
|
guint needs_swap : 1;
|
||||||
};
|
};
|
||||||
@ -114,6 +116,7 @@ struct _SysprofDocument
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ALLOCATIONS,
|
PROP_ALLOCATIONS,
|
||||||
|
PROP_BUSY,
|
||||||
PROP_COUNTERS,
|
PROP_COUNTERS,
|
||||||
PROP_CPU_INFO,
|
PROP_CPU_INFO,
|
||||||
PROP_DBUS_MESSAGES,
|
PROP_DBUS_MESSAGES,
|
||||||
@ -257,6 +260,41 @@ list_model_iface_init (GListModelInterface *iface)
|
|||||||
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofDocument, sysprof_document, G_TYPE_OBJECT,
|
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofDocument, sysprof_document, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
|
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_mark_busy (SysprofDocument *self)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_DOCUMENT (self));
|
||||||
|
|
||||||
|
if (++self->busy_count == 1)
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BUSY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_unmark_busy (SysprofDocument *self)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_DOCUMENT (self));
|
||||||
|
|
||||||
|
if (--self->busy_count == 0)
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BUSY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_mark_busy_for_task (SysprofDocument *self,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_DOCUMENT (self));
|
||||||
|
g_assert (G_IS_TASK (task));
|
||||||
|
|
||||||
|
g_signal_connect_object (task,
|
||||||
|
"notify::completed",
|
||||||
|
G_CALLBACK (sysprof_document_unmark_busy),
|
||||||
|
self,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
sysprof_document_mark_busy (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EggBitset *
|
EggBitset *
|
||||||
_sysprof_document_traceables (SysprofDocument *self)
|
_sysprof_document_traceables (SysprofDocument *self)
|
||||||
{
|
{
|
||||||
@ -373,6 +411,10 @@ sysprof_document_get_property (GObject *object,
|
|||||||
g_value_take_object (value, sysprof_document_list_allocations (self));
|
g_value_take_object (value, sysprof_document_list_allocations (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_BUSY:
|
||||||
|
g_value_set_boolean (value, sysprof_document_get_busy (self));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_COUNTERS:
|
case PROP_COUNTERS:
|
||||||
g_value_take_object (value, sysprof_document_list_counters (self));
|
g_value_take_object (value, sysprof_document_list_counters (self));
|
||||||
break;
|
break;
|
||||||
@ -443,6 +485,11 @@ sysprof_document_class_init (SysprofDocumentClass *klass)
|
|||||||
G_TYPE_LIST_MODEL,
|
G_TYPE_LIST_MODEL,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties[PROP_BUSY] =
|
||||||
|
g_param_spec_boolean ("busy", NULL, NULL,
|
||||||
|
FALSE,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
properties [PROP_COUNTERS] =
|
properties [PROP_COUNTERS] =
|
||||||
g_param_spec_object ("counters", NULL, NULL,
|
g_param_spec_object ("counters", NULL, NULL,
|
||||||
G_TYPE_LIST_MODEL,
|
G_TYPE_LIST_MODEL,
|
||||||
@ -2083,6 +2130,7 @@ sysprof_document_callgraph_async (SysprofDocument *self,
|
|||||||
|
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
g_task_set_source_tag (task, sysprof_document_callgraph_async);
|
g_task_set_source_tag (task, sysprof_document_callgraph_async);
|
||||||
|
sysprof_document_mark_busy_for_task (self, task);
|
||||||
|
|
||||||
_sysprof_callgraph_new_async (self,
|
_sysprof_callgraph_new_async (self,
|
||||||
flags,
|
flags,
|
||||||
@ -2690,6 +2738,7 @@ sysprof_document_save_async (SysprofDocument *self,
|
|||||||
|
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
g_task_set_source_tag (task, sysprof_document_save_async);
|
g_task_set_source_tag (task, sysprof_document_save_async);
|
||||||
|
sysprof_document_mark_busy_for_task (self, task);
|
||||||
|
|
||||||
bytes = g_mapped_file_get_bytes (self->mapped_file);
|
bytes = g_mapped_file_get_bytes (self->mapped_file);
|
||||||
|
|
||||||
@ -2729,3 +2778,11 @@ _sysprof_document_get_allocations (SysprofDocument *self)
|
|||||||
|
|
||||||
return egg_bitset_ref (self->allocations);
|
return egg_bitset_ref (self->allocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sysprof_document_get_busy (SysprofDocument *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), FALSE);
|
||||||
|
|
||||||
|
return self->busy_count > 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -132,5 +132,7 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
gboolean sysprof_document_save_finish (SysprofDocument *self,
|
gboolean sysprof_document_save_finish (SysprofDocument *self,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
gboolean sysprof_document_get_busy (SysprofDocument *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user