Class FWPipeLine
java.lang.Object
java.lang.Thread
net.simplace.pipe.control.FWPipeLine
- All Implemented Interfaces:
Runnable
Represents a pipeline of processors, declared as
<pipeline id="..."> with
processor and parameter children and optional lockname /
locktimedifference elements. The processors are run one after the other, each getting the
observable returned by its predecessor. A pipeline can be run in its own thread (see FWLoopProcessor) or
synchronously by calling run().
If a lock name is given, a lock file <temp dir root>/<lockname>.lock prevents that two
pipelines with the same lock name run at the same time (a lock is ignored if older than the lock time difference).
- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionFWPipeLine(org.jdom2.Element aPipelineElement, FWPipeLinesContainer aContainer) Constructs a pipeline from its XML element, creating all processors. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones the pipeline with clones of its processors, its initial parameters and its lock settings.intnet.simplace.core.FWObservableCalled after the pipeline has finished.voidprepare(net.simplace.core.FWObservable aObservable, int aNumberOfSteps) Prepares the pipeline for running.voidrun()Runs the processors in order with the prepared observable (plus the pipeline's initial parameters).voidsetAllreadyLoopedCount(int allreadyLoopedCount) Methods inherited from class Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Constructor Details
-
FWPipeLine
public FWPipeLine(org.jdom2.Element aPipelineElement, FWPipeLinesContainer aContainer) throws PipeLineCreationException Constructs a pipeline from its XML element, creating all processors.- Parameters:
aPipelineElement- thepipelineelementaContainer- the pipeline container the processors belong to- Throws:
PipeLineCreationException- if the id is missing or a processor cannot be created
-
-
Method Details
-
clone
Clones the pipeline with clones of its processors, its initial parameters and its lock settings. -
prepare
public void prepare(net.simplace.core.FWObservable aObservable, int aNumberOfSteps) Prepares the pipeline for running.- Parameters:
aObservable- the observable passed to the first processoraNumberOfSteps- maximum number of processors to run
-
getResult
public net.simplace.core.FWObservable getResult()Called after the pipeline has finished.- Returns:
- the observable returned by the last processor that was run
-
run
public void run()Runs the processors in order with the prepared observable (plus the pipeline's initial parameters). Stops after an error, when the thread is interrupted, when a processor sets the end of pipe flag or when the maximum number of steps is reached. An error of a loop processor only interrupts the thread; an error of any other processor terminates the run and is kept for the caller (seegetException()). Does nothing if the pipeline is locked. -
getException
- Returns:
- the error of a (non-loop) processor that terminated the last run, or
nullif the run ended normally
-
getProcessors
- Returns:
- the processors of the pipeline, in order
-
getAllreadyLoopedCount
public int getAllreadyLoopedCount()- Returns:
- the number of loops this pipeline was run through
-
setAllreadyLoopedCount
public void setAllreadyLoopedCount(int allreadyLoopedCount) - Parameters:
allreadyLoopedCount- the number of loops already run
-