I
- input typeO
- output typepublic class MulticoreWrapper<I,O>
extends java.lang.Object
Constructor and Description |
---|
MulticoreWrapper(int nThreads,
ThreadsafeProcessor<I,O> processor)
Constructor.
|
MulticoreWrapper(int numThreads,
ThreadsafeProcessor<I,O> processor,
boolean orderResults)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.concurrent.ThreadPoolExecutor |
buildThreadPool(int nThreads) |
void |
join()
Wait for all threads to finish, then destroy the pool of
worker threads so that the main thread can shutdown.
|
void |
join(boolean destroyThreadpool)
Wait for all threads to finish.
|
boolean |
peek()
Indicates whether or not a new result is available.
|
O |
poll()
Returns the next available result.
|
void |
put(I item)
Allocate instance to a process and return.
|
java.lang.String |
toString()
Return status information about the underlying threadpool.
|
public MulticoreWrapper(int nThreads, ThreadsafeProcessor<I,O> processor)
nThreads
- If less than or equal to 0, then automatically determine the number
of threads. Otherwise, the size of the underlying threadpool.processor
- public MulticoreWrapper(int numThreads, ThreadsafeProcessor<I,O> processor, boolean orderResults)
numThreads
- -- if less than or equal to 0, then automatically determine the number
of threads. Otherwise, the size of the underlying threadpool.processor
- orderResults
- -- If true, return results in the order submitted. Otherwise, return results
as they become available.protected java.util.concurrent.ThreadPoolExecutor buildThreadPool(int nThreads)
public java.lang.String toString()
toString
in class java.lang.Object
public void put(I item) throws java.util.concurrent.RejectedExecutionException
item
- Input to a Processorjava.util.concurrent.RejectedExecutionException
- -- A RuntimeException when there is an
uncaught exception in the queue. Resolution is for the calling class to shutdown
the wrapper and create a new threadpool.public void join()
public void join(boolean destroyThreadpool)
destroyThreadpool
- -- if true, then destroy the worker threads
so that the main thread can shutdown.public boolean peek()
public O poll()