Skip to content

Commit 8db13e3

Browse files
committed
code tidy.
1 parent c1c64df commit 8db13e3

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

affinity/src/main/java/net/openhft/affinity/LockInventory.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,32 @@
2626
class LockInventory {
2727

2828
private static final Logger LOGGER = LoggerFactory.getLogger(LockInventory.class);
29-
30-
private CpuLayout cpuLayout;
31-
32-
/**
33-
* The lock belonging to each logical core. 1-to-1 relationship
34-
*/
35-
private AffinityLock[] logicalCoreLocks;
36-
3729
/**
3830
* The locks belonging to physical cores. Since a physical core can host multiple logical cores
3931
* the relationship is one to many.
4032
*/
4133
private final NavigableMap<Integer, AffinityLock[]> physicalCoreLocks = new TreeMap<Integer, AffinityLock[]>();
34+
private CpuLayout cpuLayout;
35+
/**
36+
* The lock belonging to each logical core. 1-to-1 relationship
37+
*/
38+
private AffinityLock[] logicalCoreLocks;
4239

4340
public LockInventory(CpuLayout cpuLayout) {
4441
set(cpuLayout);
4542
}
4643

44+
public static String dumpLocks(@NotNull AffinityLock[] locks) {
45+
StringBuilder sb = new StringBuilder();
46+
for (int i = 0; i < locks.length; i++) {
47+
AffinityLock al = locks[i];
48+
sb.append(i).append(": ");
49+
sb.append(al.toString());
50+
sb.append('\n');
51+
}
52+
return sb.toString();
53+
}
54+
4755
public final synchronized CpuLayout getCpuLayout() {
4856
return cpuLayout;
4957
}
@@ -55,7 +63,7 @@ public final synchronized void set(CpuLayout cpuLayout) {
5563
reset(cpuLayout);
5664
for (int i = 0; i < cpuLayout.cpus(); i++)
5765
{
58-
final boolean base = AffinityLock.BASE_AFFINITY.get(i);;
66+
final boolean base = AffinityLock.BASE_AFFINITY.get(i);
5967
final boolean reservable = AffinityLock.RESERVED_AFFINITY.get(i);
6068

6169
LOGGER.trace("cpu " + i + " base={} reservable= {}", i, base, reservable);
@@ -172,15 +180,4 @@ private void reset(CpuLayout cpuLayout) {
172180
private int toPhysicalCore(int layoutId) {
173181
return cpuLayout.socketId(layoutId) * cpuLayout.coresPerSocket() + cpuLayout.coreId(layoutId);
174182
}
175-
176-
public static String dumpLocks(@NotNull AffinityLock[] locks) {
177-
StringBuilder sb = new StringBuilder();
178-
for (int i = 0; i < locks.length; i++) {
179-
AffinityLock al = locks[i];
180-
sb.append(i).append(": ");
181-
sb.append(al.toString());
182-
sb.append('\n');
183-
}
184-
return sb.toString();
185-
}
186183
}

0 commit comments

Comments
 (0)