Class StrandFactoryBuilder


  • public class StrandFactoryBuilder
    extends java.lang.Object
    Easily creates StrandFactorys. You can construct a new instance of this builder and use the builder pattern (call the setter methods followed by build()) to create a new StrandFactory, or use one of the static from methods to convert a ThreadFactory or FiberFactory into a StrandFactory. When using the builder pattern, either setFiber or setThread must be called prior to calling build().
    • Constructor Detail

      • StrandFactoryBuilder

        public StrandFactoryBuilder()
    • Method Detail

      • from

        public static StrandFactory from​(java.util.concurrent.ThreadFactory tf)
        Converts a ThreadFactory into a StrandFactory.
      • setThread

        public StrandFactoryBuilder setThread​(boolean daemon)
        Makes the resulting StrandFactory produce threads.
        Parameters:
        daemon - whether or not the new threads are daemon threads.
        Returns:
        this
      • setNameFormat

        public StrandFactoryBuilder setNameFormat​(java.lang.String nameFormat)
        Sets the naming format to use when naming strands (Strand.setName(java.lang.String)) which are created with this StrandFactory.
        Parameters:
        nameFormat - a String.format(String, Object...)-compatible format String, to which a unique integer (0, 1, etc.) will be supplied as the single parameter. This integer will be unique to the built instance of the StrandFactory and will be assigned sequentially. For example, "rpc-pool-%d" will generate strand names like "rpc-pool-0", "rpc-pool-1", "rpc-pool-2", etc.
        Returns:
        this
      • setStackSize

        public StrandFactoryBuilder setStackSize​(int stackSize)
        Suggests a stack size of strands created by the resulting StrandFactory. The stack size used might be an approximation of the given value, or even ignore the passed value completely.
        Parameters:
        stackSize - the stack size, in bytes
        Returns:
        this
      • setPriority

        public StrandFactoryBuilder setPriority​(int priority)
        Sets the priority for strands created by the StrandFactory. Priority currently applies only to thread, and even then the JVM and the OS are free to ignore it.
        Parameters:
        priority - the priority
        Returns:
        this