com.epam.deltix.thread.affinity.FixedAffinityLayout Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ThreadAffinity Show documentation
Show all versions of ThreadAffinity Show documentation
A wrapper over net.openhft:affinity providing handy classes to create threads pinned to the specified CPUs.
The newest version!
package com.epam.deltix.thread.affinity;
import javax.annotation.Nonnull;
import java.util.BitSet;
public class FixedAffinityLayout implements AffinityLayout {
protected final BitSet mask;
public FixedAffinityLayout(@Nonnull final BitSet mask) {
this.mask = mask;
}
public FixedAffinityLayout(final int... cpus) {
final BitSet mask = new BitSet();
for (int cpu : cpus) {
mask.set(cpu);
}
this.mask = mask;
}
@Nonnull
@Override
public BitSet getMask(@Nonnull Thread thread) {
return mask;
}
}