Skip to content

Commit 96d7475

Browse files
committed
Handle no affinity more gracefully.
1 parent 49a5b99 commit 96d7475

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717

1818
package net.openhft.affinity;
1919

20+
import net.openhft.affinity.impl.NullAffinity;
2021
import org.jetbrains.annotations.NotNull;
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
2324

2425
import java.util.NavigableMap;
2526
import java.util.TreeMap;
2627

28+
import static net.openhft.affinity.Affinity.getAffinityImpl;
29+
2730
class LockInventory {
2831

2932
private static final Logger LOGGER = LoggerFactory.getLogger(LockInventory.class);
@@ -97,6 +100,9 @@ public final synchronized void set(CpuLayout cpuLayout) {
97100
}
98101

99102
public final synchronized AffinityLock acquireLock(boolean bind, int cpuId, AffinityStrategy... strategies) {
103+
if (getAffinityImpl() instanceof NullAffinity)
104+
return noLock();
105+
100106
final boolean specificCpuRequested = !isAnyCpu(cpuId);
101107
if (specificCpuRequested && cpuId != 0) {
102108
final AffinityLock required = logicalCoreLocks[cpuId];

0 commit comments

Comments
 (0)