lttng: Add the dependency graph model and handlers for an LTTng kernel
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / internal / lttng2 / kernel / core / analysis / graph / model / LttngWorker.java
1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
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
10 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model;
11
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker;
14 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
15 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider.ProcessStatus;
16
17 /**
18 * This class represents the worker unit from the execution graph
19 *
20 * TODO: See if this class could be integrated inside HostThread instead.
21 *
22 * @author Geneviève Bastien
23 */
24 public class LttngWorker implements IGraphWorker {
25
26 private final HostThread fHostTid;
27 private final long fStart;
28
29 private String fThreadName;
30 private ProcessStatus fStatus = ProcessStatus.UNKNOWN;
31 private ProcessStatus fOldStatus = ProcessStatus.UNKNOWN;
32
33 /**
34 * Constructor
35 *
36 * @param ht
37 * The host thread represented by this worker
38 * @param name
39 * The name of this thread
40 * @param ts
41 * The timestamp
42 */
43 public LttngWorker(HostThread ht, String name, long ts) {
44 fHostTid = ht;
45 fThreadName = name;
46 fStart = ts;
47 }
48
49 @Override
50 public String getHostId() {
51 return fHostTid.getHost();
52 }
53
54 /**
55 * Set the name of this worker
56 *
57 * @param name The name of this worker
58 */
59 public void setName(String name) {
60 fThreadName = name;
61 }
62
63 /**
64 * Get the name of this worker
65 *
66 * @return The name of the worker
67 */
68 public String getName() {
69 return fThreadName;
70 }
71
72 /**
73 * Set the status, saving the old value that can still be accessed using {@link LttngWorker#getOldStatus()}
74 *
75 * @param status The new status of this
76 */
77 public void setStatus(ProcessStatus status) {
78 fOldStatus = fStatus;
79 fStatus = status;
80 }
81
82 /**
83 * Get the status of this thread
84 *
85 * @return The thread status
86 */
87 public ProcessStatus getStatus() {
88 return fStatus;
89 }
90
91 /**
92 * Return the previous status this worker was in
93 *
94 * @return The previous status of this worker
95 */
96 public ProcessStatus getOldStatus() {
97 return fOldStatus;
98 }
99
100 /**
101 * Get the host thread associated with this worker
102 *
103 * @return The {@link HostThread} associated with this worker
104 */
105 public HostThread getHostThread() {
106 return fHostTid;
107 }
108
109 /**
110 * Get the start time of this worker
111 *
112 * @return The start time in nanoseconds
113 */
114 public long getStart() {
115 return fStart;
116 }
117
118 @Override
119 public boolean equals(@Nullable Object obj) {
120 if (obj instanceof LttngWorker) {
121 return getHostThread().equals(((LttngWorker) obj).getHostThread());
122 }
123 return false;
124 }
125
126 @Override
127 public int hashCode() {
128 return fHostTid.hashCode();
129 }
130
131 @Override
132 public String toString() {
133 return '[' + fThreadName + ',' + fHostTid.getTid() + ']';
134 }
135
136 }
This page took 0.044173 seconds and 5 git commands to generate.