-void
-gui_statistic_free(StatisticViewerData *statistic_viewer_data)
-{
- if(statistic_viewer_data){
- lttvwindow_unregister_time_window_notify(statistic_viewer_data->mw,
- statistic_update_time_window,statistic_viewer_data);
- lttvwindow_unregister_show(statistic_viewer_data->mw,
- statistic_show_viewer,statistic_viewer_data);
- lttvwindow_unregister_traceset_notify(statistic_viewer_data->mw,
- statistic_traceset_changed,statistic_viewer_data);
-
- g_hash_table_destroy(statistic_viewer_data->statistic_hash);
- g_free(statistic_viewer_data->filter_key);
- g_statistic_viewer_data_list = g_slist_remove(g_statistic_viewer_data_list, statistic_viewer_data);
- g_free(statistic_viewer_data);
+
+
+/* Action to do when background computation completed.
+ *
+ * Eventually, will have to check that every requested traces are finished
+ * before doing the redraw. It will save unnecessary processor usage.
+ */
+
+static gint background_ready(void *hook_data, void *call_data)
+{
+ StatisticViewerData *svd = (StatisticViewerData *)hook_data;
+ Tab *tab = svd->tab;
+ LttvTrace *trace = (LttvTrace*)call_data;
+
+ g_debug("statistics viewer : background computation data ready.");
+
+ gtk_tree_store_clear (svd->store_m);
+
+ lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab));
+ show_traceset_stats(svd);
+
+ return 0;
+}
+
+/* Request background computation. Verify if it is in progress or ready first.
+ *
+ * Right now, for all loaded traces.
+ *
+ * Later : must be only for each trace in the tab's traceset.
+ */
+static void request_background_data(StatisticViewerData *svd)
+{
+ gint num_traces = lttvwindowtraces_get_number();
+ gint i;
+ LttvTrace *trace;
+
+ LttvHooks *background_ready_hook =
+ lttv_hooks_new();
+ lttv_hooks_add(background_ready_hook, background_ready, svd,
+ LTTV_PRIO_DEFAULT);
+
+ for(i=0;i<num_traces;i++) {
+ trace = lttvwindowtraces_get_trace(i);
+
+ if(lttvwindowtraces_get_ready(g_quark_from_string("stats"),trace)==FALSE) {
+
+ if(lttvwindowtraces_get_in_progress(g_quark_from_string("stats"),
+ trace) == FALSE) {
+ /* We first remove requests that could have been done for the same
+ * information. Happens when two viewers ask for it before servicing
+ * starts.
+ */
+ lttvwindowtraces_background_request_remove(trace, "stats");
+ lttvwindowtraces_background_request_queue(trace,
+ "stats");
+ lttvwindowtraces_background_notify_queue(svd,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+ } else { /* in progress */
+
+ lttvwindowtraces_background_notify_current(svd,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+
+ }
+ } else {
+ /* ready */
+ lttv_hooks_call(background_ready_hook, NULL);
+ }