FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
Public Member Functions | Static Public Member Functions | List of all members
CTCLLiveEventLoop Class Reference

#include <TCLLiveEventLoop.h>

Public Member Functions

void start ()
 
void start (CTCLInterpreter *pInterp)
 
void stop ()
 
long setStopLatency (long ms)
 
long getStopLatency () const
 

Static Public Member Functions

static CTCLLiveEventLoopgetInstance ()
 

Detailed Description

tclsh does not run the Tcl event loop unless, the script blocks. In that case it's not possible to continue processing commands from stdin until the event loop exits. This is not always a desireable situation in the NSCLDAQ. Sometimes we'd like to have events (like timers e.g.) in the background, or socket servers running while being live to events.

The CTCLLiveEventLoop is a class that can support this operation. It is a singleton class, since A Tcl application can only have a single event loop, however since a Tcl application may have more than one interpreter it is necessary to start the event loop on a specific interpreter. That interpreter is the one that will receive interactive commands. If the interpreter is not passed in when the event loop is started, the interpreter associated with the application is used (gpApplication).

Differnences from tclsh's input loop: prompt1 is: "% " while prompt2 is "-- " if there are no tcl_prompt1/tcl_prompt2 procs defined. If defined, those are honored.

NOTE: This class is unix specific. It uses file events which are not implemented on Windows. It ought to work just fine on Macs but has not been tested there.

Member Function Documentation

◆ getInstance()

CTCLLiveEventLoop * CTCLLiveEventLoop::getInstance ( )
static

Return a pointer to the one and only CTCLLiveEventLoop object. If this is the first call, the object is created.

◆ getStopLatency()

long CTCLLiveEventLoop::getStopLatency ( ) const

Return the stop latency. See setStopLatency for a description of this parameter.

Returns
long
Return values
Stoplatency value.
Note
If the stop latency was recently changed, the value returned may not have taken effect yet. Sorry, that's the way it goes.

◆ setStopLatency()

long CTCLLiveEventLoop::setStopLatency ( long  ms)

Set the stop latency, event loop timing. This determines how long the event loop will wait for an event before checking to see if it's time to stop running. The latency is expressed in milliseconds. Note, however that it is subject to the clock granularity, and that the less latency you request, the higher the CPU utilization of the loop.

Parameters
ms- Maximum number of milliseconds between checks of the stop flag.
Returns
long
Return values
Priorlatency value.
Note
Changes to the latency to an active event loop have the prior latency before becoming effective.
It is legal to set the latency of a stopped event loop.
The latency is not reinitialized to the default value when the event loop is started, but retains any prior value.

◆ start() [1/2]

void CTCLLiveEventLoop::start ( )

Start the event loop on the application's Tcl interpreter. note that this function will only return to the caller when another thread or an event handler invokes the stop member.

Exceptions
CStateException
  • There is no application object.
  • The event loop is already running.

◆ start() [2/2]

void CTCLLiveEventLoop::start ( CTCLInterpreter pInterp)

Start the evetn loop on the specified interpreter.

Parameters
pInterp- Pointer to the CTCLApplication that will receive commands from stdin
Exceptions
CStateException
  • Event loop is already active.

◆ stop()

void CTCLLiveEventLoop::stop ( )

This stops the event loop. The event loop waits for events up to some time out specified by setStopLatency. Between events and after waits timeout, the software will check to see if m_isRunning is still true. If not the event loop function returns.

Thus there can be a latency between stopping the event loop and it actually stopping.

Since serveral mutually unaware actors could be attempting to stop the event loop, it is not an error to stop an already stopped event loop.


The documentation for this class was generated from the following files: