|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.stanford.nlp.util.concurrent.MulticoreWrapper<I,O>
I - input typeO - output typepublic class MulticoreWrapper<I,O>
Provides convenient multicore processing for threadsafe objects. Objects that can be wrapped by MulticoreWrapper must implement the ThreadsafeProcessor interface. See edu.stanford.nlp.util.concurrent.MulticoreWrapperTest and edu.stanford.nlp.tagger.maxent.documentation.MulticoreWrapperDemo for examples of use. TODO(spenceg): Handle exceptions gracefully in the queue. TODO(spenceg): This code does not support multiple consumers, i.e., multi-threaded calls to peek() and poll().
| Constructor Summary | |
|---|---|
MulticoreWrapper(int nThreads,
ThreadsafeProcessor<I,O> processor)
Constructor. |
|
MulticoreWrapper(int numThreads,
ThreadsafeProcessor<I,O> processor,
boolean orderResults)
Constructor. |
|
| Method Summary | |
|---|---|
void |
join()
Blocks until all active processes finish. |
boolean |
peek()
Indicates whether a not a new result is available. |
O |
poll()
Returns the next available result. |
void |
put(I item)
Allocate instance to a process and return. |
void |
setMaxBlockTime(long t)
Maximum amount of time to block on a call to put() in milliseconds. |
java.lang.String |
toString()
Return status information about the underlying threadpool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
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.| Method Detail |
|---|
public void setMaxBlockTime(long t)
t - public java.lang.String toString()
toString in class java.lang.Objectpublic void put(I item)
item - Input to a Processorpublic void join()
public boolean peek()
public O poll()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||