Class GovernedAffinityPinnedThreadFactory

  • All Implemented Interfaces:
    java.util.concurrent.ThreadFactory, PinnedThreadFactory

    public final class GovernedAffinityPinnedThreadFactory
    extends java.lang.Object
    implements PinnedThreadFactory
    • Constructor Summary

      Constructors 
      Constructor Description
      GovernedAffinityPinnedThreadFactory()
      Build PinnedThread instances using the default process affinity for newly created PinnedThread instances.
      GovernedAffinityPinnedThreadFactory​(org.sheinbergon.needle.AffinityDescriptor affinityDescriptor)
      Build PinnedThread instances using the given AffinityDescriptor for newly created PinnedThread instances.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void alter​(org.sheinbergon.needle.AffinityDescriptor affinityDescriptor, boolean affectGoverned)
      Safely returns the live PinnedThread count governed by this factory.
      int governed()
      Safely returns the live PinnedThread count governed by this factory.
      org.sheinbergon.needle.PinnedThread newThread​(java.lang.Runnable r)
      Constructs a new PinnedThread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GovernedAffinityPinnedThreadFactory

        public GovernedAffinityPinnedThreadFactory()
        Build PinnedThread instances using the default process affinity for newly created PinnedThread instances.

        Note: you can set the affinity settings for both governed and future threads by calling GovernedAffinityPinnedThreadFactory#alter(Consumer) beyond the instantiation of this factory

      • GovernedAffinityPinnedThreadFactory

        public GovernedAffinityPinnedThreadFactory​(@Nonnull
                                                   org.sheinbergon.needle.AffinityDescriptor affinityDescriptor)
        Build PinnedThread instances using the given AffinityDescriptor for newly created PinnedThread instances.

        Note: you can set the affinity settings for both governed and future threads by calling GovernedAffinityPinnedThreadFactory#alter(Consumer) beyond the instantiation of this factory

        Parameters:
        affinityDescriptor - The affinity descriptor to use for creating new PinnedThread instances
    • Method Detail

      • governed

        public int governed()
        Safely returns the live PinnedThread count governed by this factory.
        Returns:
        the amount of PinnedThread instances currently governed by this factory
      • alter

        public void alter​(@Nonnull
                          org.sheinbergon.needle.AffinityDescriptor affinityDescriptor,
                          boolean affectGoverned)
        Safely returns the live PinnedThread count governed by this factory.
        Parameters:
        affinityDescriptor - The affinity descriptor to use for creating new PinnedThread instances
        affectGoverned - Whether or not the provide AffinityDescriptor should be applied to the currently governed PinnedThread set
      • newThread

        public org.sheinbergon.needle.PinnedThread newThread​(@Nonnull
                                                             java.lang.Runnable r)
        Description copied from interface: PinnedThreadFactory
        Constructs a new PinnedThread.
        Specified by:
        newThread in interface PinnedThreadFactory
        Specified by:
        newThread in interface java.util.concurrent.ThreadFactory
        Parameters:
        r - a runnable to be executed by new thread instance
        Returns:
        instantiated PinnedThread, or null if the request to create a thread is rejected