1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
;
14 import org
.eclipse
.linuxtools
.lttng
.state
.StateDataRequest
;
15 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
16 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
19 * One instance to keep track of the state of data request and a single time
20 * range data request pending in queue
25 public class DataRequestState
{
27 // ========================================================================
29 // ========================================================================
30 public enum RequestState
{
34 private TmfTimeRange queued
= null;
35 RequestState state
= RequestState
.IDLE
;
36 private StateDataRequest currentRequest
= null;
38 // ========================================================================
40 // ========================================================================
42 * @return the data request time range in queue
44 public synchronized TmfTimeRange
peekQueued() {
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
52 public synchronized TmfTimeRange
popQueued() {
53 // Save the reference to current request
54 TmfTimeRange result
= queued
;
57 // Send original reference
64 * Set the data request time range to be waiting for processing
67 * Only the latest request is preserved
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: "
76 + queued
.getStartTime() + "-"
77 + queued
.getEndTime() + "\n\t\t to: "
78 + nqueued
.getStartTime() + "-"
79 + nqueued
.getEndTime());
80 TraceDebug
.debug(sb
.toString());
84 this.queued
= nqueued
;
90 public synchronized RequestState
getState() {
98 public synchronized void setState(RequestState state
) {
102 public synchronized void setCurrentRequest(StateDataRequest currentRequest
) {
103 this.currentRequest
= currentRequest
;
106 public synchronized StateDataRequest
getCurrentRequest() {
107 return currentRequest
;