+static gint background_ready(void *hook_data, void *call_data)
+{
+ EventViewerData *event_viewer_data = (EventViewerData *)hook_data;
+ LttvTrace *trace = (LttvTrace*)call_data;
+
+ event_viewer_data->background_info_waiting--;
+
+ if(event_viewer_data->background_info_waiting == 0) {
+ g_message("event viewer : background computation data ready.");
+
+ evd_redraw_notify(event_viewer_data, NULL);
+ }
+
+ return 0;
+}
+
+
+static void request_background_data(EventViewerData *event_viewer_data)
+{
+ LttvTracesetContext * tsc =
+ lttvwindow_get_traceset_context(event_viewer_data->tab);
+ gint num_traces = lttv_traceset_number(tsc->ts);
+ gint i;
+ LttvTrace *trace;
+ LttvTraceState *tstate;
+
+ LttvHooks *background_ready_hook =
+ lttv_hooks_new();
+ lttv_hooks_add(background_ready_hook, background_ready, event_viewer_data,
+ LTTV_PRIO_DEFAULT);
+ event_viewer_data->background_info_waiting = 0;
+
+ for(i=0;i<num_traces;i++) {
+ trace = lttv_traceset_get(tsc->ts, i);
+ tstate = LTTV_TRACE_STATE(tsc->traces[i]);
+
+ if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
+ && !tstate->has_precomputed_states) {
+
+ if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
+ 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.
+ */
+ if(!lttvwindowtraces_background_request_find(trace, "state"))
+ lttvwindowtraces_background_request_queue(
+ main_window_get_widget(event_viewer_data->tab), trace, "state");
+ lttvwindowtraces_background_notify_queue(event_viewer_data,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+ event_viewer_data->background_info_waiting++;
+ } else { /* in progress */
+
+ lttvwindowtraces_background_notify_current(event_viewer_data,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+ event_viewer_data->background_info_waiting++;
+ }
+ } else {
+ /* Data ready. By its nature, this viewer doesn't need to have
+ * its data ready hook called there, because a background
+ * request is always linked with a redraw.
+ */
+ }
+
+ }
+
+ lttv_hooks_destroy(background_ready_hook);
+
+}
+