Class JCACommandThread
- java.lang.Object
-
- java.lang.Thread
-
- org.epics.archiverappliance.engine.pv.JCACommandThread
-
- All Implemented Interfaces:
Runnable
public class JCACommandThread extends Thread
JCA command pump, added for two reasons:- JCA callbacks can't directly send JCA commands without danger of a deadlock, at least not with JNI and the "DirectRequestDispatcher".
- Instead of calling 'flushIO' after each command, this thread allows for a few requests to queue up, then periodically pumps them out with only a final 'flush'
- Version:
- Initial version:CSS, 4-Jun-2012, Luofeng Li:added codes to support for the new archiver
- Author:
- Kay Kasemir
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description JCACommandThread(ConfigService configService)
Construct, but don't start the thread.
-
Method Summary
Modifier and Type Method Description void
addCommand(Runnable command)
Add a command to the queue.void
run()
void
shutdown()
Stop the thread and wait for it to finishvoid
start()
Version ofstart
that may be called multiple times.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
JCACommandThread
public JCACommandThread(ConfigService configService)
Construct, but don't start the thread.- Parameters:
configService
- ConfigService- See Also:
start()
-
-
Method Detail
-
start
public void start()
Version ofstart
that may be called multiple times.The thread must only be started after the first PV has been created. Otherwise, if flush is called without PVs, JNI JCA reports pthread errors.
NOP when already running
-
shutdown
public void shutdown() throws InterruptedException
Stop the thread and wait for it to finish- Throws:
InterruptedException
-
-
addCommand
public void addCommand(Runnable command)
Add a command to the queue. add some cap on the command queue? At least for value updates?- Parameters:
command
- Runnable
-
-