tmf: Improve histogram responsiveness
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * William Bourque - Initial API and implementation
11 * Yuriy Vashchuk - Heritage correction.
12 * Francois Chouinard - Cleanup and refactoring
13 * Francois Chouinard - Moved from LTTng to TMF
14 *******************************************************************************/
15
16 package org.eclipse.linuxtools.tmf.ui.views.histogram;
17
18 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
19 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
20 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
21 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
22 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
23 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
24
25 /**
26 * Class to request events for given time range from a trace to fill a HistogramDataModel and HistogramView.
27 *
28 * @version 1.0
29 * @author Francois Chouinard
30 * <p>
31 */
32 public class HistogramRequest extends TmfEventRequest {
33
34 // ------------------------------------------------------------------------
35 // Attributes
36 // ------------------------------------------------------------------------
37
38 /**
39 * The histogram data model to fill.
40 */
41 protected final HistogramDataModel fHistogram;
42
43 // ------------------------------------------------------------------------
44 // Constructor
45 // ------------------------------------------------------------------------
46
47 /**
48 * Constructor
49 *
50 * @param histogram
51 * The histogram data model
52 * @param range
53 * The time range to request data
54 * @param rank
55 * The index of the first event to retrieve
56 * @param nbEvents
57 * The number of events requested
58 * @param blockSize
59 * The number of events per block
60 * @param execType
61 * The requested execution priority
62 * @since 2.0
63 *
64 */
65 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
66 int rank, int nbEvents, int blockSize,
67 ITmfDataRequest.ExecutionType execType) {
68 super(ITmfEvent.class, range, rank, nbEvents,
69 (blockSize > 0) ? blockSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE,
70 execType);
71 fHistogram = histogram;
72 }
73
74 // ------------------------------------------------------------------------
75 // TmfEventRequest
76 // ------------------------------------------------------------------------
77
78 /**
79 * Handle the event from the trace by updating the histogram data model.
80 *
81 * @param event a event from the trace
82 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
83 */
84 @Override
85 public void handleData(ITmfEvent event) {
86 super.handleData(event);
87 if (event != null) {
88 long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
89 fHistogram.countEvent(getNbRead(), timestamp);
90 }
91 }
92
93 /**
94 * Complete the request. It also notifies the histogram model about the completion.
95 *
96 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
97 */
98 @Override
99 public void handleCompleted() {
100 fHistogram.complete();
101 super.handleCompleted();
102 }
103 }
This page took 0.033847 seconds and 5 git commands to generate.