public class StrandFactoryBuilder
extends java.lang.Object
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 and Description |
|---|
StrandFactoryBuilder() |
| Modifier and Type | Method and Description |
|---|---|
StrandFactory |
build()
Creates and returns the
StrandFactory that will create new strands based on this builder's settings. |
static StrandFactory |
from(FiberFactory ff)
Converts a
FiberFactory into a StrandFactory. |
static StrandFactory |
from(java.util.concurrent.ThreadFactory tf)
Converts a
ThreadFactory into a StrandFactory. |
StrandFactoryBuilder |
setFiber(FiberScheduler fs)
Makes the resulting
StrandFactory produce fibers. |
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. |
StrandFactoryBuilder |
setPriority(int priority)
Sets the priority for strands created by the
StrandFactory. |
StrandFactoryBuilder |
setStackSize(int stackSize)
Suggests a stack size of strands created by the resulting StrandFactory.
|
StrandFactoryBuilder |
setThread(boolean daemon)
Makes the resulting
StrandFactory produce threads. |
StrandFactoryBuilder |
setUncaughtExceptionHandler(Strand.UncaughtExceptionHandler ueh)
Sets the
UncaughtExceptionHandler for new threads created with this
ThreadFactory. |
public static StrandFactory from(java.util.concurrent.ThreadFactory tf)
ThreadFactory into a StrandFactory.public static StrandFactory from(FiberFactory ff)
FiberFactory into a StrandFactory.public StrandFactoryBuilder setThread(boolean daemon)
StrandFactory produce threads.daemon - whether or not the new threads are daemon threads.thispublic StrandFactoryBuilder setFiber(FiberScheduler fs)
StrandFactory produce fibers.fs - the FiberScheduler to use for the new fibers, or null for the default scheduler.thispublic StrandFactoryBuilder setNameFormat(java.lang.String nameFormat)
Strand.setName(java.lang.String)) which are created with this StrandFactory.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.thispublic StrandFactoryBuilder setStackSize(int stackSize)
stackSize - the stack size, in bytesthispublic StrandFactoryBuilder setPriority(int priority)
StrandFactory.
Priority currently applies only to thread, and even then the JVM and the OS are free to ignore it.priority - the prioritythispublic StrandFactoryBuilder setUncaughtExceptionHandler(Strand.UncaughtExceptionHandler ueh)
UncaughtExceptionHandler for new threads created with this
ThreadFactory.uncaughtExceptionHandler - the uncaught exception handlerthispublic StrandFactory build()
StrandFactory that will create new strands based on this builder's settings.StrandFactory.