1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.analysis
.graph
.model
;
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
;
18 * This class represents the worker unit from the execution graph
20 * TODO: See if this class could be integrated inside HostThread instead.
22 * @author Geneviève Bastien
24 public class LttngWorker
implements IGraphWorker
{
26 private final HostThread fHostTid
;
27 private final long fStart
;
29 private String fThreadName
;
30 private ProcessStatus fStatus
= ProcessStatus
.UNKNOWN
;
31 private ProcessStatus fOldStatus
= ProcessStatus
.UNKNOWN
;
37 * The host thread represented by this worker
39 * The name of this thread
43 public LttngWorker(HostThread ht
, String name
, long ts
) {
50 public String
getHostId() {
51 return fHostTid
.getHost();
55 * Set the name of this worker
57 * @param name The name of this worker
59 public void setName(String name
) {
64 * Get the name of this worker
66 * @return The name of the worker
68 public String
getName() {
73 * Set the status, saving the old value that can still be accessed using {@link LttngWorker#getOldStatus()}
75 * @param status The new status of this
77 public void setStatus(ProcessStatus status
) {
83 * Get the status of this thread
85 * @return The thread status
87 public ProcessStatus
getStatus() {
92 * Return the previous status this worker was in
94 * @return The previous status of this worker
96 public ProcessStatus
getOldStatus() {
101 * Get the host thread associated with this worker
103 * @return The {@link HostThread} associated with this worker
105 public HostThread
getHostThread() {
110 * Get the start time of this worker
112 * @return The start time in nanoseconds
114 public long getStart() {
119 public boolean equals(@Nullable Object obj
) {
120 if (obj
instanceof LttngWorker
) {
121 return getHostThread().equals(((LttngWorker
) obj
).getHostThread());
127 public int hashCode() {
128 return fHostTid
.hashCode();
132 public String
toString() {
133 return '[' + fThreadName
+ ',' + fHostTid
.getTid() + ']';