org.jlab.coda.cMsg
Class cMsgCallbackThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.jlab.coda.cMsg.cMsgCallbackThread
All Implemented Interfaces:
java.lang.Runnable

public class cMsgCallbackThread
extends java.lang.Thread

This class is used to run a message callback in its own thread. The thread is self-starting and waits to execute the callback. All it needs is a notify.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
cMsgCallbackThread(cMsgCallbackInterface callback, java.lang.Object arg, java.lang.String domain, java.lang.String subject, java.lang.String type)
          Constructor.
 
Method Summary
 void dieNow(boolean callInterrupt)
          This method kills this thread as soon as possible.
 java.lang.Object getArg()
          Gets the user argument.
 cMsgCallbackInterface getCallback()
          Gets the callback object.
 int getCount()
          Gets the number of identical subscriptions.
 int getCueSize()
          Gets the number of messages in the cue.
 long getMsgCount()
          Gets the number of messages passed to the callback.
 void run()
          This method is executed as a thread which runs the callback method
 void sendMessage(cMsgMessageFull message)
          Put message on a cue of messages waiting to be taken by the callback.
 void setCount(int count)
          Sets the number of identical subscriptions.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

cMsgCallbackThread

public cMsgCallbackThread(cMsgCallbackInterface callback,
                          java.lang.Object arg,
                          java.lang.String domain,
                          java.lang.String subject,
                          java.lang.String type)
Constructor.

Parameters:
callback - callback to be run when message arrives
arg - user-supplied argument for callback
domain -
subject -
type -
Method Detail

dieNow

public void dieNow(boolean callInterrupt)
This method kills this thread as soon as possible. If unsubscribe or disconnect is called in a callback using the same connection, then the subscribe or disconnect will interrupt the callback currently calling them. To avoid this, set the argument to false.

Parameters:
callInterrupt - if true interrupt is called on callback thread, else interrupt is not called.

getMsgCount

public long getMsgCount()
Gets the number of messages passed to the callback.

Returns:
number of messages passed to the callback

getCueSize

public int getCueSize()
Gets the number of messages in the cue.

Returns:
number of messages in the cue

getCallback

public cMsgCallbackInterface getCallback()
Gets the callback object.

Returns:
user callback object

getArg

public java.lang.Object getArg()
Gets the user argument.

Returns:
user argument object

getCount

public int getCount()
Gets the number of identical subscriptions.

Returns:
the number of identical subscriptions

setCount

public void setCount(int count)
Sets the number of identical subscriptions.

Parameters:
count - the number of identical subscriptions

sendMessage

public void sendMessage(cMsgMessageFull message)
Put message on a cue of messages waiting to be taken by the callback.

Parameters:
message - message to be passed to callback

run

public void run()
This method is executed as a thread which runs the callback method

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread