com.epam.deltix.thread.affinity.CompositeAffinityLayout 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 javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.BitSet;
@ParametersAreNonnullByDefault
public class CompositeAffinityLayout implements AffinityLayout {
protected final ArrayList layouts = new ArrayList<>();
public void addLayout(@Nonnull AffinityLayout layout) {
layouts.add(layout);
}
public void removeLayout(@Nonnull AffinityLayout layout) {
layouts.remove(layout);
}
@Override
@Nonnull
public BitSet getMask(@Nonnull Thread thread) {
BitSet result = new BitSet();
for (AffinityLayout layout : layouts) {
BitSet mask = layout.getMask(thread);
result.or(mask);
}
return result;
}
}