MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
asyConMgr.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1998 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #ifndef VXWORKS
12 
13 #include <rtiMsConfig.h>
14 #include <connectMgr.h>
15 #include <fedAmbCallbackQueue.h>
16 
17 #include "fedAmbCallbackQueue.h"
18 
19 #include <vlutil/vlThreadSafe.h>
20 #include <vlutil/vlMutex.h>
21 #include <vlutil/vlLockfreeQueue.h>
22 
23 #ifdef _WIN32
24 #include "windows.h"
25 #else
26 #include "pthread.h"
27 #include <vlutil/vlSelectParamW.h>
28 #endif
29 
30 
31 namespace MAKRti
32 {
33  class DtSelectParamWithWrite;
34 }
36 
38 {
39 
40 public:
41 
42  DtQueuePacket( DtRtiMsg* msg,
43  MAKRti::DtTransportType transport,
44  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
45 
46  ~DtQueuePacket();
47 
49  MAKRti::DtInetAddr addr;
50  MAKRti::DtTransportType transport;
51 };
52 
53 typedef MAKRti::DtLockfreeQueue<DtQueuePacket*> DtAsycQueueType;
54 
59 
61 {
62 protected:
63 
64  DtAsyncConnectionMgr( DtRIDParameters* params, bool isFederate = false,
65  std::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
66  std::shared_ptr<DtRtiAssistantLrcClient>() );
67 
68 public:
69 
70  virtual ~DtAsyncConnectionMgr();
71 
77  virtual int init( DtRIDParameters* params );
78 
80  virtual void setFederateMgr( DtFederateMgr* fedMgrPtr );
81 
83  virtual void shutdown();
84 
86  virtual bool isAsynchronous();
87 
88  virtual void disconnectFederation();
89 
90  virtual void connectFederation(
91 #if defined(DtIFSPEC13) || defined(DtIFSPEC1516)
92  RTI_API::FederateAmbassador* fedAmb,
93 #endif
94  DtLogicalTimeFactory* logicalTimeFactoryPtr,
95  MAKRti::DtString fedExName,
96  DtFederateHandle fedHandle,
97  int fedExHandle );
98 
100  virtual int send( const DtRtiMsg& msg,
101  MAKRti::DtTransportType transport,
102  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
103 
106  virtual int sendAndDelete( DtRtiMsg* msg,
107  MAKRti::DtTransportType transport,
108  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
109 
111  virtual bool tick();
112 
117  virtual bool processConnections();
118 
121  virtual DtRtiMsg* getMessage();
122 
124  virtual DtNetReadStatus handleMsg( DtRtiMsg& msg );
125 
130  virtual bool flush();
131 
133  virtual void receiveThread();
134  virtual void sendThread();
135 
138  virtual bool wait( MAKRti::DtTime periodInSeconds, bool unlockWhileWaiting = false );
139 
148  virtual int readFileDescriptor(DtRtiApiTransportationType transport);
149 
150 #ifdef _WIN32
151  virtual HANDLE waitEvent();
153 
156  virtual WSAEVENT readFileEvent(DtRtiApiTransportationType transport);
157 #else
158  virtual int waitEvent();
160 #endif
161 
164  virtual void signalReceiveEvent();
165 
168  virtual void clearReceiveEvent();
169 
172  virtual void signalSendEvent();
173 
176  virtual void clearSendEvent();
177 
179  virtual void yield();
180 
184  virtual bool processConnectionsInCallback();
185 
186 protected:
187 
190  virtual bool repairFederationConnection() override;
191 
193  virtual bool waitForConnectionRepair() const;
194 
197  virtual bool doReceiveProcessing(unsigned long timeout);
198 
200  virtual void doDisconnectFederation();
201 
203  virtual bool doWait(MAKRti::DtTime period);
204 
206  virtual void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg);
207 
212  virtual bool sendPackets();
213 
219  virtual DtNetReadStatus receivePacket(DtRtiConnection* conn,
220  MAKRti::DtTransportType transportType, unsigned int& receivedPacketCount);
221 
226  virtual bool receivePackets();
227 
230  virtual void queueMsg(DtRtiMsg* msg,
231  MAKRti::DtTransportType transport,
232  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny());
233 
237  virtual DtNetReadStatus processMsgQueueCallbacks(DtRtiMsg& msg,
238  unsigned int& receivedPacketCount);
239 
242  virtual void processPendingMsgQueueCallbacks();
243 
245  virtual void processPendingMsgMakeCallbacks();
246 
248  virtual void setMessageTracking(DtRtiMsg& msg);
249 
252  virtual void destroyPackets();
253 
255  virtual void destroyRelConn();
256 
258  virtual void destroyAncillaryRelConn(DtRtiConnection* conn);
259 
261  virtual void destroyAncillaryRelConns();
262 
264  virtual void startAsynchronousReceiveProcessing();
265  virtual void startAsynchronousSendProcessing();
266 
268  virtual void stopAsynchronousReceiveProcessing();
269  virtual void stopAsynchronousSendProcessing();
270 
273  inline DtQueuePacket* getPacket();
274 
277  virtual bool createBestEffortConn();
278 
283  virtual bool queueReceivePacket(DtRtiMsg* rtiMessage, MAKRti::DtTransportType transportType,
284  bool& overflowWarning);
285 
288  virtual void testIoIndicator(const char* label, unsigned int queueLevel,
289  unsigned int& lowWaterLine, unsigned int& highWaterLine, bool& overflowWarning);
290 
291 public:
292 
294  static DtConnectionMgr* create( DtRIDParameters* p, bool isFederate = false,
295  std::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
296  std::shared_ptr<DtRtiAssistantLrcClient>() );
297 
299 #ifdef _WIN32
300  static unsigned long runReceive( void* usr );
301  static unsigned long runSend( void* usr );
302 #else
303  static void* runReceive( void* usr );
304  static void* runSend( void* usr );
305 #endif
306 
307 protected:
308 
310  static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr);
311 
312 protected:
323  bool myNonReflectedList[DtInvalidMsgKind + 1];
325 
326 #ifdef _WIN32
327  HANDLE myReceiveThreadHandle;
328  HANDLE mySendThreadHandle;
329  HANDLE myReceiveWaitEvent;
330  HANDLE* myWaitEvents;
331  HANDLE mySendWaitEvent;
332  unsigned int myNumWaitEvents;
333 #else
334  DtSelectParamWithWrite myWaitEventsParams;
337  int mySendEvent[2];
338  int myRecvEvent[2];
339 #endif
340 
342  DtMutex* myRepairMutex;
343 
346 
349 
350  float myIoPeriod;
352  unsigned int myMaxQueue;
353  unsigned int myMaxCount;
354 
356  unsigned int mySendPacketCount;
357  unsigned int myReadPacketCount;
358 
365 
367  DtCallbackQueue* myCallbackQueue;
368 
369  DtThreadSafe<bool> myAsynchronousConnectionIsOk;
370 
375 
378 #ifdef _WIN32
379  unsigned int myWaitEvent_BestEffortConn;
380  unsigned int myWaitEvent_PrimaryReliableConn;
381  unsigned int myWaitEvent_AncillaryReliableConnStart;
382  unsigned int myNoBestEffort;
383 #endif
384 
385  unsigned int myIoQueueIndicator;
392 
397 
398  char myRecvEventBuffer[100];
399  char mySendEventBuffer[100];
400 };
401 
402 #endif
403 
virtual void destroyAncillaryRelConn(DtRtiConnection *conn)
Destroy the given ancillary reliable connection.
pthread_t myReceiveThreadHandle
Definition: asyConMgr.h:335
unsigned int myIoQueueIndicator
These are pointers to the locations in the WaitEvent list they need to be dynamic in case one of them...
Definition: asyConMgr.h:385
virtual bool processConnections()
Check all the connections and process any incomming messages Return boolean: message was received...
virtual DtRtiMsg * getMessage()
Get a message if one exists Message must be destroyed by caller.
MAKRti::DtLockfreeQueue< DtQueuePacket * > DtAsycQueueType
Definition: asyConMgr.h:53
bool myReserved
Definition: asyConMgr.h:320
float myTickWaitPeriod
Definition: asyConMgr.h:351
DtAsycQueueType * mySendQueue
Exchange queues between federate and IO threads these lists are used in asynchronous mode...
Definition: asyConMgr.h:363
DtNetReadStatus
Definition: connection.h:21
pthread_t mySendThreadHandle
Definition: asyConMgr.h:336
virtual bool processConnectionsInCallback()
unsigned int myReadPacketCount
Definition: asyConMgr.h:357
This class manages the RTI&#39;s start-up configuration using both MTL variables and functions.
Definition: RIDparams.h:87
Definition: fedTimeFactory.h:73
virtual bool doWait(MAKRti::DtTime period)
perform actual wait. Called by wait
unsigned int mySendQueueLowWaterLine
Definition: asyConMgr.h:389
RTI_API::TransportationTypeHandle DtRtiApiTransportationType
Definition: rtiApiTypes.h:114
This class represents a network connection with another RTI component.
Definition: connection.h:38
bool myTimeToQuitSending
Definition: asyConMgr.h:313
bool mySendOverflowWarning
Definition: asyConMgr.h:391
bool myAsynchronousProcessMsg
Definition: asyConMgr.h:319
the Asynchronous Connection Mgr adds asynchronous I/O to the connectionMgr class. ...
Definition: asyConMgr.h:60
MAKRti::DtTransportType transport
Definition: asyConMgr.h:50
Includes either 1.3 or 1516 federate ambassador callback queue.
bool myTimeToQuitReceiving
Definition: asyConMgr.h:314
float myIoPeriod
Definition: asyConMgr.h:350
This file contains the declaration of the Connection Manager.
virtual int send(const DtRtiMsg &msg, MAKRti::DtTransportType transport, const MAKRti::DtInetAddr &addr=MAKRti::DtInetAddr::inaddrAny())
Sending.
virtual void setFederateMgr(DtFederateMgr *fedMgrPtr)
Set the federate manager.
bool myAsynchronousCallbacks
Definition: asyConMgr.h:318
Note: no message kind may be &gt; DtInvalidMsgKind This is a limitation imposed by the RTI Msg Header - ...
Definition: rtiMsgKind.h:162
virtual void shutdown()
Request shutdown of communication activities.
unsigned int myReceiveQueueLowWaterLine
Definition: asyConMgr.h:386
virtual void yield()
Yield processing to allow more data to arrive.
DtRtiMsg * msg
Definition: asyConMgr.h:48
virtual void disconnectFederation()
The LRC disassociates its connections from the federation.
bool myAsynchronous
Definition: asyConMgr.h:317
virtual bool flush()
Send buffered messages.
unsigned int mySendPacketCount
Number of packets until time to yield (== max count)
Definition: asyConMgr.h:356
unsigned int myMaxCount
Definition: asyConMgr.h:353
DtThreadSafe< bool > myAsynchronousConnectionIsOk
Definition: asyConMgr.h:369
Instances of DtFederateMgr process federation-level messages (such as create, destroy, join, resign, and sync points) and manages the objects responsible for handling general communication, objects, interactions, the FOM, MOM, and data distribution mmg.
Definition: fedMgr.h:93
virtual void destroyAncillaryRelConns()
Destroy ancillary reliable connections.
DtAsycQueueType * myReceiveQueue
Definition: asyConMgr.h:364
Instances of DtConnectionMgr manage the communication objects that the RTI will use to either communi...
Definition: connectMgr.h:67
int myInPostTick
Definition: asyConMgr.h:324
virtual void destroyRelConn()
Destroy reliable connection.
DtRtiMsg is the base class for messages between RTI components.
Definition: rtiMsg.h:34
DtHandle DtFederateHandle
Definition: internalTypes.h:46
virtual bool repairFederationConnection()
Attempt to re-establish a broken connection to the federation Returns true if successful.
unsigned int myNextReliableConnToRead
Mechanism to track which reliable connection to fetch packets from when multiple ancillary reliable c...
Definition: asyConMgr.h:374
virtual int readFileDescriptor(DtRtiApiTransportationType transport)
Returns a file descriptor on which data will be present for the given transport type whenever there i...
unsigned int mySendQueueHighWaterLine
Definition: asyConMgr.h:390
MAKRti::DtInetAddr addr
Definition: asyConMgr.h:49
Definition: asyConMgr.h:37
bool myDoDisconnect
Definition: asyConMgr.h:322
DtMutex * myRepairMutex
Mutex to synchronize access to connection repair lock.
Definition: asyConMgr.h:342
unsigned int myMaxQueue
Definition: asyConMgr.h:352
virtual bool createBestEffortConn()
Create best effort connection; Returns true if successful Could be that it already exist in which cas...
bool myReadyToRepair
Indicates that connection is ready to repair (used to coordinate repair with asynchronous processing)...
Definition: asyConMgr.h:348
virtual bool tick()
Receiving.
bool mySendThreadActivated
Definition: asyConMgr.h:315
virtual void connectFederation(DtLogicalTimeFactory *logicalTimeFactoryPtr, MAKRti::DtString fedExName, DtFederateHandle federateHandle, int fedExHandle)
The LRC associates its federation information with its network connections.
unsigned int myReceiveQueueHighWaterLine
Definition: asyConMgr.h:387
#define DT_DLL_LRC
Definition: rtiMsConfig.h:155
bool myReceiveThreadActivated
Definition: asyConMgr.h:316
bool myShouldWaitOnCurrentBundle
This determines whether the send thread should sleep after it attempts to send all packets...
Definition: asyConMgr.h:396
virtual int init(DtRIDParameters *params)
Initialize the RTI&#39;s exercise parameters and connections Users who wish to override the MAK RTI&#39;s net...
bool myConnectionIsUnderRepair
Indicates that connection is under repair (used to coordinate repair with asynchronous processing) ...
Definition: asyConMgr.h:345
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 Returns the size of the data sent...
virtual DtRtiMsg * create(DtRtiMsgKind kind)
Request the RTI message factory for a msg.
bool myReceiveOverflowWarning
Definition: asyConMgr.h:388
virtual DtNetReadStatus handleMsg(DtRtiMsg &msg)
Handle this message by either processing it or queuing it if save pending.
bool myMoreToFlush
Definition: asyConMgr.h:321
DtCallbackQueue * myCallbackQueue
A federate ambassador wrapper that queues up federate ambassador calls.
Definition: asyConMgr.h:367
A message that delivers stored callbacks generated by asynchronous thread.
Definition: fedAmbCallbackMsg.h:34
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 rea...
DtSelectParamWithWrite myWaitEventsParams
Definition: asyConMgr.h:334

Document ID: Generated on Wed Jul 8 16:20:32 EDT 2026 from SVN revision 291616
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)