public final class OctaveExec extends Object
| Modifier and Type | Field and Description |
|---|---|
private boolean |
destroyed |
private ReaderWriterPipeThread |
errorStreamThread
The error thread of the error stream of
process
writing the error stream to a given writer. |
private ExecutorService |
executor
Used in method
evalRW(WriteFunctor, ReadFunctor)
to submit essentially the write functor which submits the input
and thereafter the read function which collects the output. |
private static org.apache.commons.logging.Log |
LOG |
static String |
MSG_EXE_NH |
static String |
MSG_IOE_NH |
static String |
MSG_RTE_NH |
private Process |
process
The octave process created in the constructor
with given command, arguments, environment and working directory.
|
private BufferedReader |
processReader
The input reader for
process. |
private Writer |
processWriter |
private Random |
random |
| Constructor and Description |
|---|
OctaveExec(int numThreadsReuse,
Writer stdinLog,
Writer stderrLog,
String[] cmdArray,
String[] environment,
File workingDir)
Will start the octave process.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the octave process in an orderly fashion.
|
void |
destroy()
Kill the octave process without remorse.
|
void |
evalRW(WriteFunctor input,
ReadFunctor output)
Passes
input to octave
and get back output. |
private String |
generateSpacer() |
private RuntimeException |
getFromFuture(Future<Void> future)
Completes computation on future
and returns an exception thrown or null.
|
private boolean |
isDestroyed()
Returns
destroyed. |
private OctaveException |
reInstException(OctaveException exc)
Used by
getFromFuture(Future)
to reinstantiate an OctaveException
if this occurs as the cause of an ExecutionException. |
private void |
setDestroyed(boolean destroyed)
Sets
destroyed to the parameter value given. |
void |
setErrorWriter(Writer writer) |
public static final String MSG_IOE_NH
public static final String MSG_EXE_NH
public static final String MSG_RTE_NH
private static final org.apache.commons.logging.Log LOG
private final Process process
private final Writer processWriter
private final BufferedReader processReader
process.
This is used by evalRW(WriteFunctor, ReadFunctor)
and used to close via close().private final ExecutorService executor
evalRW(WriteFunctor, ReadFunctor)
to submit essentially the write functor which submits the input
and thereafter the read function which collects the output.
Besides this, the executor is invoked to shutdown.private final ReaderWriterPipeThread errorStreamThread
process
writing the error stream to a given writer.
This is used to close but also to change the error writer
by setErrorWriter(Writer).private boolean destroyed
private final Random random
public OctaveExec(int numThreadsReuse,
Writer stdinLog,
Writer stderrLog,
String[] cmdArray,
String[] environment,
File workingDir)
numThreadsReuse - the number of threads to be reused in a fixed thread pool.
This is either positive or -1,
which means that a cached thread pool is used instead of a fixed one.stdinLog - This writer will capture all
that is written to the octave process via stdin,
if null the data will not be captured.stderrLog - This writer will capture all
that is written from the octave process on stderr,
if null the data will not be captured.cmdArray - The array consisting of command and arguments:
The 0th entry is either the path to the octave program,
or the command found by looking at the builtin variable "paths"
reconstructing the path.
starting with the 1th entry,
may follow the array of arguments to start the octave program with.
CAUTION: allowed values depend on the octave version.environment - The environment for the octave process,
i.e. the set of values of environment variables
if null the process will inherit the environment
for the virtual machine.
If not null, each entry has the form name=value.workingDir - This will be the working dir for the octave process,
if null the process will inherit the working dir
of the current process.private String generateSpacer()
public void evalRW(WriteFunctor input, ReadFunctor output)
input to octave
and get back output.input - a write functor which represents the script
to be executed in octave.output - the read functor which reads the result of octave execution.
After evaluation of this method,
the output is asked for the result.private RuntimeException getFromFuture(Future<Void> future)
private OctaveException reInstException(OctaveException exc)
getFromFuture(Future)
to reinstantiate an OctaveException
if this occurs as the cause of an ExecutionException.private void setDestroyed(boolean destroyed)
destroyed to the parameter value given.private boolean isDestroyed()
destroyed.public void destroy()
public void close()
public void setErrorWriter(Writer writer)
writer - the new writer to write the error output toCopyright © 2006–2018 Simuline Organization (l2r). All rights reserved.