|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.asyncobjects.vats.VatRunner net.sf.asyncobjects.vats.ExecutorRunner
public class ExecutorRunner
This runner is being run over some Executor
service. Note that it
requres executor to execute tasks asynchronously. The blocking or direct
execution when calling Executor.execute(Runnable)
will cause
deadlocks.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.sf.asyncobjects.vats.VatRunner |
---|
VatRunner.VatRunnerState |
Field Summary |
---|
Fields inherited from class net.sf.asyncobjects.vats.VatRunner |
---|
state, stateLock |
Constructor Summary | |
---|---|
ExecutorRunner(Executor executor)
A constructor of executor |
Method Summary | |
---|---|
static ThreadFactory |
getThreadFactory(ThreadFactory factory,
String namePrefix,
Boolean isDaemon)
Get thread factory |
protected boolean |
hasEvents(Vat vat,
Object ticket)
This method is called by the vat when new events have arrived. |
static ExecutorRunner |
newCachedRunner()
Creates new runner over executor created by Executors.newCachedThreadPool() . |
static ExecutorRunner |
newCachedRunner(String namePrefix)
Creates new runner over executor created by Executors.newCachedThreadPool(ThreadFactory) . |
static ExecutorRunner |
newCachedRunner(String namePrefix,
Boolean isDaemon)
Creates new runner over executor created by Executors.newCachedThreadPool(ThreadFactory) . |
static ExecutorRunner |
newCachedRunner(ThreadFactory threadFactory)
Creates new runner over executor created by Executors.newCachedThreadPool(ThreadFactory) . |
static ExecutorRunner |
newCachedRunner(ThreadFactory threadFactory,
String namePrefix,
Boolean isDaemon)
Creates new runner over executor created by Executors.newCachedThreadPool(ThreadFactory) . |
static ExecutorRunner |
newFixedThreadPoolRunner(int nThreads)
Creates new runner over fixed size thread pool |
static ExecutorRunner |
newFixedThreadPoolRunner(int nThreads,
Boolean isDaemon)
Creates new runner over fixed size thread pool |
static ExecutorRunner |
newFixedThreadPoolRunner(int nThreads,
String namePrefix)
Creates new runner over fixed size thread pool |
static ExecutorRunner |
newFixedThreadPoolRunner(int nThreads,
String namePrefix,
Boolean isDaemon)
Creates new runner over fixed size thread pool |
static ExecutorRunner |
newFixedThreadPoolRunner(int nThreads,
ThreadFactory threadFactory,
String namePrefix,
Boolean isDaemon)
Creates new runner over fixed size thread pool |
Methods inherited from class net.sf.asyncobjects.vats.VatRunner |
---|
cancelledEqueuedVat, getBachingFactor, getState, newVat, newVat, setBachingFactor, setStarted, setStarting, setState, setStopped, setStopping |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExecutorRunner(Executor executor)
executor
- an exector to useMethod Detail |
---|
protected boolean hasEvents(Vat vat, Object ticket)
VatRunner
hasEvents
in class VatRunner
vat
- a vat that has new events and is associated with the runnerticket
- a ticket from the vat
VatRunner.hasEvents(net.sf.asyncobjects.vats.Vat,
java.lang.Object)
public static ExecutorRunner newCachedRunner(ThreadFactory threadFactory)
Executors.newCachedThreadPool(ThreadFactory)
. Note that batching
factor for this runner is Integer.MAX_VALUE
because using other
values will have almost the same effect but with lesser efficiency due to
unnecessary context setting.
threadFactory
- a thread factory
public static ExecutorRunner newCachedRunner()
Executors.newCachedThreadPool()
.
public static ExecutorRunner newCachedRunner(ThreadFactory threadFactory, String namePrefix, Boolean isDaemon)
Executors.newCachedThreadPool(ThreadFactory)
.
threadFactory
- thread factorynamePrefix
- name prefix. if null prefix is ignoredisDaemon
- if thread should be created as daemon threads
public static ExecutorRunner newCachedRunner(String namePrefix, Boolean isDaemon)
Executors.newCachedThreadPool(ThreadFactory)
.
namePrefix
- name prefix. if null prefix is ignoredisDaemon
- if thread should be created as daemon threads
public static ExecutorRunner newCachedRunner(String namePrefix)
Executors.newCachedThreadPool(ThreadFactory)
.
namePrefix
- name prefix. if null prefix is ignored
public static ExecutorRunner newFixedThreadPoolRunner(int nThreads, ThreadFactory threadFactory, String namePrefix, Boolean isDaemon)
nThreads
- number of threadsthreadFactory
- thread factorynamePrefix
- name prefix. if null prefix is ignoredisDaemon
- if thread should be created as daemon threads
public static ExecutorRunner newFixedThreadPoolRunner(int nThreads, String namePrefix, Boolean isDaemon)
nThreads
- number of threadsnamePrefix
- name prefix. if null prefix is ignoredisDaemon
- if thread should be created as daemon threads
public static ExecutorRunner newFixedThreadPoolRunner(int nThreads, Boolean isDaemon)
nThreads
- number of threadsisDaemon
- if thread should be created as daemon threads
public static ExecutorRunner newFixedThreadPoolRunner(int nThreads, String namePrefix)
nThreads
- number of threadsnamePrefix
- name prefix. if null prefix is ignored
public static ExecutorRunner newFixedThreadPoolRunner(int nThreads)
nThreads
- number of threads
public static ThreadFactory getThreadFactory(ThreadFactory factory, String namePrefix, Boolean isDaemon)
factory
- a factorynamePrefix
- a name prefix for new threadsisDaemon
- a value of isDaemon parameters
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |