Update FSF address
[lttv.git] / lttv / modules / gui / lttvwindow / lttvwindow / computetrace.c
CommitLineData
911b7a3c 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
b9ce0bad
YB
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
911b7a3c 17 */
18
4e4d11b3 19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
911b7a3c 22
23/* This file does not even compile yet. It is a starting point to compute
24 some values in the background. This is why process_trace was split in
25 three. However, process_trace_middle as it is currently is would not work.
26 It needs to reinitialize its trace event positions each time since,
27 in between background calls to process middle, other foreground calls to
28 process_middle can happen. */
29
30#include <lttvwindow/idleprocesstrace.h>
31
32/* The calling function has checked that the needed information has not
33 been or is not being computed yet, has prepared the trace, and now all
34 that is needed is to queue it for processing.
35
36 CHECK remove the work_queue global variable, have an automatic adjustment
37 of the number of events to process by iteration. */
38
39static gboolean inserted = false;
40
41static GList *work_queue = NULL;
42
43typedef struct _WorkPiece WorkPiece;
44
45struct _WorkPiece {
46 LttvTracesetContext *self;
47 LttTime end;
48 unsigned nb_events;
49 LttvHook f;
50 void *hook_data;
51 unsigned nb_done;
52}
53
54guint lttv_process_traceset_piece(gpointer data)
55{
56 GList *first = g_list_first(work_queue);
57
58 guint nb_done, nb_asked;
59
60 if(first == NULL) {
61 inserted = false;
62 return false;
63 }
64
65 WorkPiece *work_piece = (WorkPiece *)first->data;
66 nb_asked = work_piece->nb_events - work_piece->nb_done;
67 nb_asked = min(nb_asked, 10000);
68 nb_done = lttv_process_trace_middle(work_piece->self,work_piece->end,
69 nb_asked);
70 work_piece->nb_done += nb_done;
71 if(nb_done < nb_asked) {
72 lttv_process_trace_end(work_piece->self);
73 work_queue = g_list_delete(work_queue, first);
74 }
75}
76
77
78void lttv_process_traceset_when_idle(LttvTracesetContext *self, LttTime end,
79 unsigned nb_events, LttvHook f, void *hook_data)
80{
81 WorkPiece *work_piece = g_new(WorkPiece);
82 work_piece->self = self;
83 work_piece->end = end;
84 work_piece->nb_events = nb_events;
85 work_piece->f = f;
86 work_piece->hook_data = hook_data;
87 eork_piece->nb_done = 0;
88
89 lttv_process_traceset_begin(self);
90 work_queue = g_list_append(work_queue, work_piece);
91 if(!inserted) g_idle_add(lttv_process_traceset_piece, work_queue);
92}
93
94
This page took 0.071254 seconds and 4 git commands to generate.