MAK RTIspy API Documentation for HLA 1516
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
DtAsyncConnectionMgr Class Reference

the Asynchronous Connection Mgr adds asynchronous I/O to the connectionMgr class. More...

+ Inheritance diagram for DtAsyncConnectionMgr:
+ Collaboration diagram for DtAsyncConnectionMgr:

List of all members.

Public Member Functions

virtual ~DtAsyncConnectionMgr ()
virtual int init (DtRIDParameters *params)
 Initialize the RTI's exercise connections Users who wish to override the MAK RTI's network connections should override this function After the network connections are set it up creates a thread to monitor the sockets.
virtual void setFederateMgr (DtFederateMgr *fedMgrPtr)
 Set the federate manager.
virtual bool isAsynchronous ()
 return if in asynchronous mode
virtual void disconnectFederation ()
 The LRC disassociates its connections from the federation.
virtual void connectFederation (DtLogicalTimeFactory *logicalTimeFactoryPtr, MAKRti::DtString fedExName, DtFederateHandle fedHandle, int fedExHandle)
 The LRC associates its federation information with its network connections.
virtual void queueMsg (DtRtiMsg *msg, MAKRti::DtTransportType transport, const MAKRti::DtInetAddr &addr=MAKRti::DtInetAddr::inaddrAny())
 method uses a mutex to lock the send queue while adding a a packet to the queue
virtual int send (const DtRtiMsg &msg, MAKRti::DtTransportType transport, const MAKRti::DtInetAddr &addr=MAKRti::DtInetAddr::inaddrAny())
 Send a message.
virtual int sendAndDelete (DtRtiMsg *msg, MAKRti::DtTransportType transport, const MAKRti::DtInetAddr &addr=MAKRti::DtInetAddr::inaddrAny())
 Send a message and delete the message after it has been sent Retraction record of timestamped messages must made here.
virtual bool tick ()
 Process the connections for sychronous IO or callbacks.
virtual bool processConnections ()
 Check all the connections and process any incomming messages Return boolean: message was received? (i.e.
virtual DtRtiMsggetMessage ()
 Get a message if one exists Message must be destroyed by caller.
virtual DtNetReadStatus handleMsg (DtRtiMsg &msg)
 Handle this message by either processing it or queueing it if save pending.
virtual bool flush ()
 Does nothing in Async.
virtual void workerThread ()
 worker thread (called by run)
virtual bool wait (MAKRti::DtTime periodInSeconds, bool unlockWhileWaiting=false)
 Wait for data to be ready or the given period of time to expire Return boolean: data is ready for reading?
virtual int readFileDescriptor (RTI::TransportType transport)
 Returns a file descriptor on which data will be present for the given transport type whenever there is incoming data waiting to be read.
virtual int waitEvent ()
 return the waiting handle
virtual void signalReceiveEvent ()
 Signal the receive event Used by IO thread to signal federate thread.
virtual void clearReceiveEvent ()
 Clear receive event Used by federate thread to clear signal.
virtual void signalSendEvent ()
 Signal the send event Used by federate thread to signal IO thread.
virtual void clearSendEvent ()
 Clear send event Used by IO thread to clear signal.
virtual void yield ()
 Yield processing to allow more data to arrive.

Static Public Member Functions

static DtConnectionMgrcreate (DtRIDParameters *p, bool isFederate=false, DtBoost::shared_ptr< DtRtiAssistantLrcClient > assistantClient=DtBoost::shared_ptr< DtRtiAssistantLrcClient >())
 Creator function.
static void * run (void *usr)
 thread start calls worker thread

Protected Member Functions

 DtAsyncConnectionMgr (DtRIDParameters *params, bool isFederate=false, DtBoost::shared_ptr< DtRtiAssistantLrcClient > assistantClient=DtBoost::shared_ptr< DtRtiAssistantLrcClient >())
virtual bool doWait (MAKRti::DtTime period)
 Perform actual wait, called by wait function.
virtual void processCallbackMsg (const DtFedAmbCallbackMsg &callbackMsg)
 Message callback.
virtual DtQueuePacketgetPacket ()
 Get a packet off of receive buffer Receive buffer is refreshed if empty.
virtual bool sendPackets ()
 Send buffered packets.
virtual DtNetReadStatus receivePacket (DtRtiConnection *conn, MAKRti::DtTransportType transportType, unsigned int &receivedPacketCount)
 Process a packet from the given connection.
virtual bool receivePackets ()
 Process connections and either place packets in receive queue or process messages directly if asynchronous callbacks are enabled.
virtual DtNetReadStatus processMsgQueueCallbacks (DtRtiMsg &msg, unsigned int &receivedPacketCount)
 Process message but queue any resulting federate ambassador callbacks.
virtual void processPendingMsgQueueCallbacks ()
 Process a pending message but queue any resulting federate ambassador callbacks.
virtual void processPendingMsgMakeCallbacks ()
 Process a pending message and make any resulting federate ambassador callbacks.
virtual void setMessageTracking (DtRtiMsg &msg)
 Set the appropriate tracking values in the message.
virtual void waitOnIO (DtSelectParamWithWrite &params)
 Make processing wait on IO.
virtual void destroyPackets ()
 Destroy any packets in the send and receive buffers and queues.
virtual void destroyRelConn ()
 Destroy reliable connection.
virtual void destroyAncillaryRelConn (DtRtiConnection *conn)
 Destroy the given ancillary reliable connection.
virtual void destroyAncillaryRelConns ()
 Destroy ancillary reliable connections.

Static Protected Member Functions

static void processCallbackMsg (const DtFedAmbCallbackMsg &callbackMsg, void *usr)
 Message callback.

Protected Attributes

bool myTimeToQuit
bool myThreadActivated
bool myAsynchronous
bool myAsynchronousCallbacks
bool myAsynchronousProcessMsg
bool myReserved
bool myMoreToFlush
DtMutex * mySendLock
DtMutex * myReceiveLock
pthread_t myThreadHandle
int mySendEvent [2]
int myRecvEvent [2]
float myIoPeriod
float myTickWaitPeriod
unsigned int myMaxQueue
unsigned int myMaxCount
unsigned int myLockQueue
long myReceivedBufferCurrent
 Federate thread buffers.
long myReceivedBufferCount
DtQueuePacket ** myReceivedBuffer
unsigned int myCurrentSendPacket
 IO thread buffers.
unsigned int myPacketsToSendCount
std::vector< DtQueuePacket * > mySendPacketBuffer
std::vector< DtQueuePacket * > myRecvPacketBuffer
unsigned int myReadPacketCount
 Number of packets read until time to yield (== max count)
MAKRti::DtClock myBestEffortRetryTimer
 Mechanism to retry best effort transmits which block.
unsigned int myBestEffortRetryAttempts
MAKRti::DtTime myBestEffortTimeToRetry
MAKRti::DtList * mySendQueue
 Exchange queues between federate and IO threads these lists are used in asynchronous mode.
MAKRti::DtList * myReceiveQueue
DtCallbackQueue * myCallbackQueue
 A federate ambassador wrapper that queues up federate ambassador calls.
DtThreadSafe< boolmyAsynchronousConnectionIsOk
unsigned int myNextReliableConnToRead
 Mechanism to track which reliable connection to fetch packets from when multiple ancillary reliable connections exist.

Detailed Description

the Asynchronous Connection Mgr adds asynchronous I/O to the connectionMgr class.

A thread is created to manage the send and receive queues. It can operate in a synchronous mode if the myAsynchronous flag is set to false.


Constructor & Destructor Documentation

DtAsyncConnectionMgr::DtAsyncConnectionMgr ( DtRIDParameters params,
bool  isFederate = false,
DtBoost::shared_ptr< DtRtiAssistantLrcClient assistantClient = DtBoost::shared_ptr<DtRtiAssistantLrcClient>() 
) [protected]

Member Function Documentation

Clear receive event Used by federate thread to clear signal.

References myRecvEvent.

Referenced by doWait(), and getPacket().

Clear send event Used by IO thread to clear signal.

References mySendEvent.

Referenced by workerThread().

void DtAsyncConnectionMgr::connectFederation ( DtLogicalTimeFactory logicalTimeFactoryPtr,
MAKRti::DtString  fedExName,
DtFederateHandle  federateHandle,
int  fedExHandle 
) [virtual]

The LRC associates its federation information with its network connections.

If the LRC is communicating with the rtiexec through a reliable connection, then the best effort connection is created here.

Reimplemented from DtConnectionMgr.

References DtWaitEvent_AncillaryReliableConnStart, DtWaitEvent_BestEffortConn, DtWaitEvent_PrimaryReliableConn, DtWaitEvent_Send, myAsynchronous, myMoreToFlush, myReceivedBuffer, myThreadActivated, myThreadHandle, myTimeToQuit, NULL, DtConnectionMgr::reliableConn(), and run().

DtConnectionMgr * DtAsyncConnectionMgr::create ( DtRIDParameters p,
bool  isFederate = false,
DtBoost::shared_ptr< DtRtiAssistantLrcClient assistantClient = DtBoost::shared_ptr<DtRtiAssistantLrcClient>() 
) [static]

Creator function.

Reimplemented from DtConnectionMgr.

References DtAsyncConnectionMgr().

Referenced by DtRtiAmbassadorBaseImplementor::setupConnection().

void DtAsyncConnectionMgr::destroyAncillaryRelConn ( DtRtiConnection conn) [protected, virtual]

Destroy the given ancillary reliable connection.

Reimplemented from DtConnectionMgr.

References myNextReliableConnToRead.

void DtAsyncConnectionMgr::destroyAncillaryRelConns ( ) [protected, virtual]

Destroy ancillary reliable connections.

Reimplemented from DtConnectionMgr.

References myNextReliableConnToRead.

void DtAsyncConnectionMgr::destroyPackets ( ) [protected, virtual]

Destroy any packets in the send and receive buffers and queues.

The buffers and queues themselves are not destroyed

References isAsynchronous(), myCurrentSendPacket, myLockQueue, myPacketsToSendCount, myReceivedBuffer, myReceivedBufferCount, myReceivedBufferCurrent, myReceiveQueue, myRecvPacketBuffer, mySendPacketBuffer, and mySendQueue.

Referenced by disconnectFederation(), workerThread(), and ~DtAsyncConnectionMgr().

void DtAsyncConnectionMgr::destroyRelConn ( ) [protected, virtual]

Destroy reliable connection.

Reimplemented from DtConnectionMgr.

References myNextReliableConnToRead.

Referenced by receivePackets(), and sendPackets().

The LRC disassociates its connections from the federation.

If the LRC is communicating with the rtiexec through a reliable connection, then the best effort connection is destroyed here.

Reimplemented from DtConnectionMgr.

References destroyPackets(), DtConnectionMgr::myCallbackMutex, myCurrentSendPacket, DtConnectionMgr::myFedMgr, DtConnectionMgr::myInService, DtConnectionMgr::myLockService, myMoreToFlush, myPacketsToSendCount, mySendQueue, myThreadActivated, myThreadHandle, myTimeToQuit, DtFederateMgr::posttick(), and sendPackets().

bool DtAsyncConnectionMgr::doWait ( MAKRti::DtTime  period) [protected, virtual]

Perform actual wait, called by wait function.

Reimplemented from DtConnectionMgr.

References clearReceiveEvent(), myRecvEvent, myTickWaitPeriod, DtConnectionMgr::params(), period, and signalSendEvent().

Referenced by wait().

Does nothing in Async.

I/O mode In sync. I/O mode, Flush the send queues Send buffered messages. Returns indication of whether flush is complete or incomplete.

Reimplemented from DtConnectionMgr.

References myThreadActivated.

Get a message if one exists Message must be destroyed by caller.

Reimplemented from DtConnectionMgr.

References DtRtiMsg::cloneWithTransport(), getPacket(), DtQueuePacket::msg, and myThreadActivated.

DtQueuePacket * DtAsyncConnectionMgr::getPacket ( ) [protected, virtual]

Get a packet off of receive buffer Receive buffer is refreshed if empty.

References clearReceiveEvent(), myLockQueue, myReceivedBuffer, myReceivedBufferCount, myReceivedBufferCurrent, myReceiveLock, myReceiveQueue, and myThreadActivated.

Referenced by getMessage(), and processConnections().

int DtAsyncConnectionMgr::init ( DtRIDParameters params) [virtual]

return if in asynchronous mode

References myAsynchronous.

Referenced by destroyPackets(), and ~DtAsyncConnectionMgr().

void DtAsyncConnectionMgr::processCallbackMsg ( const DtFedAmbCallbackMsg callbackMsg) [protected, virtual]
void DtAsyncConnectionMgr::processCallbackMsg ( const DtFedAmbCallbackMsg callbackMsg,
void *  usr 
) [static, protected]

Message callback.

Check all the connections and process any incomming messages Return boolean: message was received? (i.e.

could be more input). method uses a mutex to receive the send queue while adding a packet to the queue

Reimplemented from DtConnectionMgr.

References getPacket(), handleMsg(), DtQueuePacket::msg, myAsynchronousConnectionIsOk, and myThreadActivated.

DtNetReadStatus DtAsyncConnectionMgr::processMsgQueueCallbacks ( DtRtiMsg msg,
unsigned int &  receivedPacketCount 
) [protected, virtual]

Process message but queue any resulting federate ambassador callbacks.

Packet count is incremented if messages placed on receive buffer. Return status of message processing.

References DtTestManager::addAsyncQueueMsgOnRecieve(), DtNET_READ_NO_PACKETS, DtNET_READ_SUCCESS, handleMsg(), DtConnectionMgr::lockServiceCall(), myCallbackQueue, DtConnectionMgr::myFedMgr, myLockQueue, myRecvPacketBuffer, DtFederateMgr::posttick(), DtFederateMgr::testMgr(), and DtConnectionMgr::unlockServiceCall().

Referenced by receivePacket().

Process a pending message but queue any resulting federate ambassador callbacks.

Any resulting callback messages are put on receive queue.

References DtConnectionMgr::lockServiceCall(), myCallbackQueue, DtConnectionMgr::myFedMgr, myReceiveLock, myReceiveQueue, myTimeToQuit, DtFederateMgr::posttick(), DtConnectionMgr::processPendingMsg(), signalReceiveEvent(), and DtConnectionMgr::unlockServiceCall().

Referenced by workerThread().

void DtAsyncConnectionMgr::queueMsg ( DtRtiMsg msg,
MAKRti::DtTransportType  transport,
const MAKRti::DtInetAddr &  addr = MAKRti::DtInetAddr::inaddrAny() 
) [virtual]

method uses a mutex to lock the send queue while adding a a packet to the queue

References DtConnectionMgr::myFedMgr, myIoPeriod, myMaxQueue, mySendLock, mySendQueue, myThreadActivated, DtTestManager::queueMsgForSend(), signalSendEvent(), and DtFederateMgr::testMgr().

Referenced by send(), and sendAndDelete().

Returns a file descriptor on which data will be present for the given transport type whenever there is incoming data waiting to be read.

Returns -1 if no such file descriptor.

On windows, always returns -1, use readFileEvent instead. On unix returns the file descriptor of the pipe used for inter-thread communication instead of the socket file descriptor. Transport type is ignored.

Reimplemented from DtConnectionMgr.

References DtConnectionMgr::readFileDescriptor().

DtNetReadStatus DtAsyncConnectionMgr::receivePacket ( DtRtiConnection conn,
MAKRti::DtTransportType  transportType,
unsigned int &  receivedPacketCount 
) [protected, virtual]

Process a packet from the given connection.

Depending on processing mode and the packet contents, the packet may result in messages placed on receive buffer. Packet count is incremented if messages are placed on receive buffer. Returns status of read on connection

References DtTestManager::addReceiveTimeStampIfNecessary(), DtRtiMsg::clone(), DtNET_READ_NO_PACKETS, handleMsg(), myAsynchronousCallbacks, myAsynchronousProcessMsg, myCallbackQueue, DtConnectionMgr::myFedMgr, myLockQueue, myReadPacketCount, myRecvPacketBuffer, DtRtiConnection::netRead(), processMsgQueueCallbacks(), DtConnectionMgr::processReadResult(), DtRtiMsg::setTransportType(), and DtFederateMgr::testMgr().

Referenced by receivePackets().

bool DtAsyncConnectionMgr::receivePackets ( ) [protected, virtual]
void * DtAsyncConnectionMgr::run ( void *  usr) [static]

thread start calls worker thread

References workerThread().

Referenced by connectFederation().

int DtAsyncConnectionMgr::send ( const DtRtiMsg msg,
MAKRti::DtTransportType  transport,
const MAKRti::DtInetAddr &  addr = MAKRti::DtInetAddr::inaddrAny() 
) [virtual]
int DtAsyncConnectionMgr::sendAndDelete ( DtRtiMsg msg,
MAKRti::DtTransportType  transport,
const MAKRti::DtInetAddr &  addr = MAKRti::DtInetAddr::inaddrAny() 
) [virtual]
bool DtAsyncConnectionMgr::sendPackets ( ) [protected, virtual]
void DtAsyncConnectionMgr::setFederateMgr ( DtFederateMgr fedMgrPtr) [virtual]
void DtAsyncConnectionMgr::setMessageTracking ( DtRtiMsg msg) [protected, virtual]

Signal the receive event Used by IO thread to signal federate thread.

References myRecvEvent, and myThreadActivated.

Referenced by processPendingMsgQueueCallbacks(), and receivePackets().

Signal the send event Used by federate thread to signal IO thread.

References DtWaitEvent_Send, mySendEvent, and myThreadActivated.

Referenced by doWait(), queueMsg(), and yield().

Process the connections for sychronous IO or callbacks.

Reimplemented from DtConnectionMgr.

References myAsynchronousCallbacks, and myThreadActivated.

bool DtAsyncConnectionMgr::wait ( MAKRti::DtTime  periodInSeconds,
bool  unlockWhileWaiting = false 
) [virtual]

return the waiting handle

References myRecvEvent.

void DtAsyncConnectionMgr::waitOnIO ( DtSelectParamWithWrite &  params) [protected, virtual]

Make processing wait on IO.

References myIoPeriod, myMoreToFlush, mySendEvent, and DtConnectionMgr::reliableConn().

Referenced by workerThread().

void DtAsyncConnectionMgr::yield ( ) [virtual]

Yield processing to allow more data to arrive.

Reimplemented from DtConnectionMgr.

References signalSendEvent().


Member Data Documentation

Referenced by sendPackets().

MAKRti::DtClock DtAsyncConnectionMgr::myBestEffortRetryTimer [protected]

Mechanism to retry best effort transmits which block.

Referenced by init(), and sendPackets().

Referenced by sendPackets().

DtCallbackQueue* DtAsyncConnectionMgr::myCallbackQueue [protected]

A federate ambassador wrapper that queues up federate ambassador calls.

Referenced by processMsgQueueCallbacks(), processPendingMsgQueueCallbacks(), receivePacket(), setFederateMgr(), and ~DtAsyncConnectionMgr().

IO thread buffers.

Referenced by destroyPackets(), disconnectFederation(), init(), sendPackets(), and workerThread().

Referenced by init(), queueMsg(), and waitOnIO().

unsigned int DtAsyncConnectionMgr::myLockQueue [protected]
unsigned int DtAsyncConnectionMgr::myMaxCount [protected]

Referenced by init(), and workerThread().

unsigned int DtAsyncConnectionMgr::myMaxQueue [protected]

Referenced by init(), and queueMsg().

Mechanism to track which reliable connection to fetch packets from when multiple ancillary reliable connections exist.

Must be set to zero whenever reliable connection is deleted.

Referenced by destroyAncillaryRelConn(), destroyAncillaryRelConns(), destroyRelConn(), and receivePackets().

unsigned int DtAsyncConnectionMgr::myReadPacketCount [protected]

Number of packets read until time to yield (== max count)

Referenced by init(), receivePacket(), and workerThread().

Referenced by destroyPackets(), getPacket(), init(), and wait().

Federate thread buffers.

Referenced by destroyPackets(), getPacket(), and init().

MAKRti::DtList* DtAsyncConnectionMgr::myReceiveQueue [protected]
DtMutex* DtAsyncConnectionMgr::mySendLock [protected]

Referenced by destroyPackets(), init(), and sendPackets().

MAKRti::DtList* DtAsyncConnectionMgr::mySendQueue [protected]

Exchange queues between federate and IO threads these lists are used in asynchronous mode.

They contain pointers to DtQueuePacket's. They are not used when not operating asynchronously

Referenced by destroyPackets(), disconnectFederation(), init(), queueMsg(), sendPackets(), workerThread(), and ~DtAsyncConnectionMgr().

pthread_t DtAsyncConnectionMgr::myThreadHandle [protected]

Referenced by doWait(), and init().


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

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)