+#if 0
+typedef struct _ProcessAddClosure {
+ ControlFlowData *cfd;
+ guint trace_num;
+} ProcessAddClosure;
+
+static void process_add(gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ LttvProcessState *process = (LttvProcessState*)value;
+ ProcessAddClosure *closure = (ProcessAddClosure*)user_data;
+ ControlFlowData *control_flow_data = closure->cfd;
+ guint trace_num = closure->trace_num;
+
+ /* Add process to process list (if not present) */
+ guint pid;
+ LttTime birth;
+ guint y = 0, height = 0, pl_height = 0;
+
+ ProcessList *process_list =
+ guicontrolflow_get_process_list(control_flow_data);
+
+ pid = process->pid;
+ birth = process->creation_time;
+ const gchar *name = g_quark_to_string(process->name);
+ HashedProcessData *hashed_process_data = NULL;
+
+ if(processlist_get_process_pixels(process_list,
+ pid,
+ &birth,
+ trace_num,
+ &y,
+ &height,
+ &hashed_process_data) == 1)
+ {
+ /* Process not present */
+ processlist_add(process_list,
+ pid,
+ &birth,
+ trace_num,
+ name,
+ &pl_height,
+ &hashed_process_data);
+ processlist_get_process_pixels(process_list,
+ pid,
+ &birth,
+ trace_num,
+ &y,
+ &height,
+ &hashed_process_data);
+ drawing_insert_square( control_flow_data->drawing, y, height);
+ }
+}
+#endif //0
+
+
+/* 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.
+ */
+
+gint background_ready(void *hook_data, void *call_data)
+{
+ ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
+ LttvTrace *trace = (LttvTrace*)call_data;
+ LttvTracesetContext *tsc =
+ lttvwindow_get_traceset_context(control_flow_data->tab);
+
+ g_debug("control flow viewer : background computation data ready.");
+
+ drawing_clear(control_flow_data->drawing);
+ processlist_clear(control_flow_data->process_list);
+#if 0
+ {
+ gint num_traces = lttv_traceset_number(tsc->ts);
+ gint i;
+ LttvTraceState *ts;
+ ProcessAddClosure closure;
+ closure.cfd = control_flow_data;
+
+ for(i=0;i<num_traces;i++) {
+ ts = (LttvTraceState*)tsc->traces[i];
+
+ closure.trace_num = i;
+
+ /* add all the processes to the list */
+ lttv_state_for_each_process(ts, (GHFunc)process_add, &closure);
+ }
+ }
+#endif //0
+ redraw_notify(control_flow_data, NULL);
+
+ 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.
+ */
+void request_background_data(ControlFlowData *control_flow_data)
+{
+ 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, control_flow_data,
+ LTTV_PRIO_DEFAULT);
+
+ for(i=0;i<num_traces;i++) {
+ trace = lttvwindowtraces_get_trace(i);
+
+ if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
+
+ 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.
+ */
+ lttvwindowtraces_background_request_remove(trace, "state");
+ lttvwindowtraces_background_request_queue(trace,
+ "state");
+ lttvwindowtraces_background_notify_queue(control_flow_data,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+ } else { /* in progress */
+
+ lttvwindowtraces_background_notify_current(control_flow_data,
+ trace,
+ ltt_time_infinite,
+ NULL,
+ background_ready_hook);
+
+ }
+ }
+ }
+
+ lttv_hooks_destroy(background_ready_hook);
+}
+
+
+
+