[219097] LTTng updates
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / common / DataRequestState.java
1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.common;
13
14 import org.eclipse.linuxtools.lttng.state.StateDataRequest;
15 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
16 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
17
18 /**
19 * One instance to keep track of the state of data request and a single time
20 * range data request pending in queue
21 *
22 * @author alvaro
23 *
24 */
25 public class DataRequestState {
26
27 // ========================================================================
28 // Data
29 // ========================================================================
30 public enum RequestState {
31 IDLE, BUSY
32 }
33
34 private TmfTimeRange queued = null;
35 RequestState state = RequestState.IDLE;
36 private StateDataRequest currentRequest = null;
37
38 // ========================================================================
39 // Methods
40 // ========================================================================
41 /**
42 * @return the data request time range in queue
43 */
44 public synchronized TmfTimeRange peekQueued() {
45 return queued;
46 }
47
48 /**
49 * @return the data request time range in queue and reset it reference to
50 * null to get ready for a new entry in queue
51 */
52 public synchronized TmfTimeRange popQueued() {
53 // Save the reference to current request
54 TmfTimeRange result = queued;
55 // remove from queue
56 queued = null;
57 // Send original reference
58 return result;
59 }
60
61 /**
62 * @param queued
63 * <p>
64 * Set the data request time range to be waiting for processing
65 * </p>
66 * <p>
67 * Only the latest request is preserved
68 * </p>
69 */
70 public synchronized void setQueued(TmfTimeRange nqueued) {
71 if (TraceDebug.isDEBUG()) {
72 if (this.queued != null) {
73 StringBuilder sb = new StringBuilder(
74 "Queued request replaced from: "
75
76 + queued.getStartTime() + "-"
77 + queued.getEndTime() + "\n\t\t to: "
78 + nqueued.getStartTime() + "-"
79 + nqueued.getEndTime());
80 TraceDebug.debug(sb.toString());
81 }
82 }
83
84 this.queued = nqueued;
85 }
86
87 /**
88 * @return the state
89 */
90 public synchronized RequestState getState() {
91 return state;
92 }
93
94 /**
95 * @param state
96 * the state to set
97 */
98 public synchronized void setState(RequestState state) {
99 this.state = state;
100 }
101
102 public synchronized void setCurrentRequest(StateDataRequest currentRequest) {
103 this.currentRequest = currentRequest;
104 }
105
106 public synchronized StateDataRequest getCurrentRequest() {
107 return currentRequest;
108 }
109
110 }
This page took 0.032952 seconds and 5 git commands to generate.