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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.trace
;
15 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
18 * <b><u>TmfTraceContext</u></b>
20 * Trace context keeper. It ties a trace location to an event index and
21 * timestamp. The context should be enough to restore the trace state
22 * so the corresponding event can be read.
24 * Used to handle conflicting, concurrent accesses to the trace.
26 public class TmfTraceContext
{
28 private Object location
;
29 private TmfTimestamp timestamp
;
32 public TmfTraceContext(Object loc
, TmfTimestamp ts
, long ind
) {
34 timestamp
= (ts
!= null) ? ts
: TmfTimestamp
.BigBang
;
38 public TmfTraceContext(TmfTraceContext other
) {
39 this(other
.location
, other
.timestamp
, other
.index
);
42 public Object
getLocation() {
43 // validateLocation(location);
47 public void setLocation(Object loc
) {
48 // validateLocation(loc);
52 public TmfTimestamp
getTimestamp() {
56 public void setTimestamp(TmfTimestamp ts
) {
60 public void setIndex(long value
) {
64 public long getIndex() {
68 public void incrIndex() {
72 // TODO: Generalize this code so an implementor can troubleshoot concurrency issues
74 // // ========================================================================
75 // // Toubleshooting code
76 // // ========================================================================
78 // static private DataInputStream in;
79 // static private int size = 100001;
80 // static private long offsets[] = new long[size];
81 // static public void init() {
82 // System.out.println("TmfTraceContext: Loading valid offsets...");
84 // in = new DataInputStream(new BufferedInputStream(new FileInputStream("Offsets.dat")));
85 // for (int i = 0; i < size; i++)
86 // offsets[i] = in.readLong();
87 // } catch (FileNotFoundException e) {
88 // // TODO Auto-generated catch block
89 // e.printStackTrace();
90 // } catch (IOException e) {
91 // // TODO Auto-generated catch block
92 // e.printStackTrace();
94 // System.out.println("TmfTraceContext: Done.");
97 // private boolean bsearch(long key) {
100 // while (first < last) {
101 // int mid = (first + last) / 2;
102 // if (key < offsets[mid]) {
104 // } else if (key > offsets[mid]) {
113 // private void validateLocation(Object loc) {
114 // long l = (Long) loc;
115 // if (!bsearch(l)) {
116 // System.out.println("TmfTraceContext: location is invalid!");
This page took 0.03394 seconds and 5 git commands to generate.