All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.epam.deltix.thread.affinity.CompositeAffinityLayout Maven / Gradle / Ivy

Go to download

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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy