public class ConcurrentTranslator extends java.lang.Object implements Translator
Translator
concurrently, making use
of the specified number of threads. The input is read line by line and each
of them translated by the underlying Translator
concurrently.Constructor and Description |
---|
ConcurrentTranslator(Translator translator)
Constructs a new translator that will make use of as many threads as this
machine can run concurrently.
|
ConcurrentTranslator(Translator translator,
int nThreads)
Constructs a new translator.
|
ConcurrentTranslator(Translator translator,
int nThreads,
int queueSize)
Constructs a new translator.
|
Modifier and Type | Method and Description |
---|---|
void |
translate(java.io.Reader in,
TranslationWriter out)
Creates a partial translation for the given input text.
|
public ConcurrentTranslator(Translator translator)
translator
- the actual Translator
that will perform the translation.public ConcurrentTranslator(Translator translator, int nThreads)
translator
- the actual Translator
that will perform the translation.nThreads
- the number of threads that the translator should make use of.public ConcurrentTranslator(Translator translator, int nThreads, int queueSize)
translator
- the actual Translator
that will perform the translation.nThreads
- the number of threads that the translator should make use of.queueSize
- the maximum amount of elements to keep in the output queue before ceasing to consume more input until some space is made.public void translate(java.io.Reader in, TranslationWriter out)
Translator
translate
in interface Translator
in
- the Reader
to read the input from.out
- the TranslationWriter
with which to write the output.