mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
ui: use g_atomic_rc_box
This changes a couple of our structures to use the atomic rc box instead of gslice directly. It shouldn't affect anything, just some general modernization while looking at #23
This commit is contained in:
@ -51,11 +51,16 @@ typedef struct
|
||||
G_DEFINE_TYPE (SysprofDepthVisualizer, sysprof_depth_visualizer, SYSPROF_TYPE_VISUALIZER)
|
||||
|
||||
static void
|
||||
state_free (State *st)
|
||||
state_clear (State *st)
|
||||
{
|
||||
g_clear_pointer (&st->reader, sysprof_capture_reader_unref);
|
||||
g_clear_pointer (&st->pc, point_cache_unref);
|
||||
g_slice_free (State, st);
|
||||
}
|
||||
|
||||
static void
|
||||
state_unref (State *st)
|
||||
{
|
||||
g_atomic_rc_box_release_full (st, (GDestroyNotify) state_clear);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -179,7 +184,7 @@ sysprof_depth_visualizer_reload (SysprofDepthVisualizer *self)
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
|
||||
|
||||
st = g_slice_new0 (State);
|
||||
st = g_atomic_rc_box_new0 (State);
|
||||
st->reader = sysprof_capture_reader_ref (self->reader);
|
||||
st->pc = point_cache_new ();
|
||||
st->max_n_addrs = 0;
|
||||
@ -193,7 +198,7 @@ sysprof_depth_visualizer_reload (SysprofDepthVisualizer *self)
|
||||
|
||||
task = g_task_new (self, NULL, apply_point_cache_cb, NULL);
|
||||
g_task_set_source_tag (task, sysprof_depth_visualizer_reload);
|
||||
g_task_set_task_data (task, st, (GDestroyNotify) state_free);
|
||||
g_task_set_task_data (task, st, (GDestroyNotify) state_unref);
|
||||
g_task_run_in_thread (task, sysprof_depth_visualizer_worker);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user