com.epam.deltix.thread.affinity.FallbackAffinityLayout Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thread-affinity Show documentation
Show all versions of thread-affinity 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 FallbackAffinityLayout implements AffinityLayout {
protected final AffinityLayout layout;
protected final BitSet fallback;
public FallbackAffinityLayout(@Nonnull final AffinityLayout layout, @Nonnull final BitSet fallback) {
this.layout = layout;
this.fallback = fallback;
}
@Nonnull
@Override
public BitSet getMask(@Nonnull final Thread thread) {
final BitSet mask = layout.getMask(thread);
return mask.isEmpty() ? fallback : mask;
}
}