1 /*******************************************************************************
2 * Copyright (c) 2014 É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
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.analysis
.vm
.model
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
18 import com
.google
.common
.collect
.HashBasedTable
;
19 import com
.google
.common
.collect
.Table
;
22 * This class represents a virtual CPU, which is a CPU running on a guest. It
23 * associates the guest CPU ID to a virtual machine of the model.
25 * @author Geneviève Bastien
27 public class VirtualCPU
{
29 private static final Table
<VirtualMachine
, Long
, @Nullable VirtualCPU
> VIRTUAL_CPU_TABLE
= NonNullUtils
.checkNotNull(HashBasedTable
.create());
31 private final VirtualMachine fVm
;
32 private final Long fCpuId
;
35 * Return the virtual CPU for to the virtual machine and requested CPU ID
41 * @return the virtual CPU
43 public static synchronized VirtualCPU
getVirtualCPU(VirtualMachine vm
, Long cpu
) {
44 VirtualCPU ht
= VIRTUAL_CPU_TABLE
.get(vm
, cpu
);
46 ht
= new VirtualCPU(vm
, cpu
);
47 VIRTUAL_CPU_TABLE
.put(vm
, cpu
, ht
);
52 private VirtualCPU(VirtualMachine vm
, Long cpu
) {
58 * Get the CPU ID of this virtual CPU
60 * @return The zero-based CPU ID
62 public Long
getCpuId() {
67 * Get the virtual machine object this virtual CPU belongs to
69 * @return The guest Virtual Machine
71 public VirtualMachine
getVm() {
76 public String
toString() {
77 return "VirtualCPU: [" + fVm
+ ',' + fCpuId
+ ']'; //$NON-NLS-1$
This page took 0.042585 seconds and 5 git commands to generate.