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 <vlutil/vlThreadSafe.h>
16 #include <vlutil/vlMutex.h>
17 #include "fedAmbCallbackQueue.h"
18 #include <vlutil/vlLockfreeQueue.h>
19 
20 #ifdef _WIN32
21 #include "windows.h"
22 #else
23 #include "pthread.h"
24 #include <vlutil/vlSelectParamW.h>
25 #endif
26 
27 #ifdef DtIFSPEC13DLC
28 #define RTI rti13
29 #endif
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  DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
66  DtBoost::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  virtual void connectFederation(
90 #ifdef DtIFSPEC1516
91  rti1516::FederateAmbassador* fedAmb,
92 #elif defined(DtIFSPEC13)
93  RTI::FederateAmbassador* fedAmb,
94 #endif
95  DtLogicalTimeFactory* logicalTimeFactoryPtr,
96  MAKRti::DtString fedExName,
97  DtFederateHandle fedHandle,
98  int fedExHandle );
99 
102  virtual void queueMsg( DtRtiMsg* msg,
103  MAKRti::DtTransportType transport,
104  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
105 
107  virtual int send( const DtRtiMsg& msg,
108  MAKRti::DtTransportType transport,
109  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
110 
113  virtual int sendAndDelete( DtRtiMsg* msg,
114  MAKRti::DtTransportType transport,
115  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
116 
118  virtual bool tick();
119 
124  virtual bool processConnections();
125 
128  virtual DtRtiMsg* getMessage();
129 
131  virtual DtNetReadStatus handleMsg( DtRtiMsg& msg );
132 
137  virtual bool flush();
138 
140  virtual void receiveThread();
141  virtual void sendThread();
142 
145  virtual bool wait( MAKRti::DtTime periodInSeconds, bool unlockWhileWaiting = false );
146 
155 #ifdef DtIFSPEC1516
156  virtual int readFileDescriptor(rti1516::TransportationType transport);
157 #elif defined(DtIFSPEC1516E)
158  virtual int readFileDescriptor(rti1516e::TransportationType transport);
159 #else
160  virtual int readFileDescriptor(RTI::TransportType transport);
161 #endif
162 
163 #ifdef _WIN32
164  virtual HANDLE waitEvent();
168 #ifdef DtIFSPEC1516
169  virtual WSAEVENT readFileEvent(rti1516::TransportationType transport);
170 #elif defined(DtIFSPEC1516E)
171  virtual WSAEVENT readFileEvent(rti1516e::TransportationType transport);
172 #else
173  virtual WSAEVENT readFileEvent(RTI::TransportType transport);
174 #endif
175 #else
176  virtual int waitEvent();
178 #endif
179 
182  virtual void signalReceiveEvent();
183 
186  virtual void clearReceiveEvent();
187 
190  virtual void signalSendEvent();
191 
194  virtual void clearSendEvent();
195 
197  virtual void yield();
198 
202  virtual bool processConnectionsInCallback();
203 
204 protected:
205 
208  virtual bool doReceiveProcessing(unsigned long timeout);
209 
211  virtual void doDisconnectFederation();
212 
214  virtual bool doWait(MAKRti::DtTime period);
215 
217  virtual void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg);
218 
223  virtual bool sendPackets();
224 
230  virtual DtNetReadStatus receivePacket(DtRtiConnection* conn,
231  MAKRti::DtTransportType transportType, unsigned int& receivedPacketCount);
232 
237  virtual bool receivePackets();
238 
242  virtual DtNetReadStatus processMsgQueueCallbacks(DtRtiMsg& msg,
243  unsigned int& receivedPacketCount);
244 
247  virtual void processPendingMsgQueueCallbacks();
248 
250  virtual void processPendingMsgMakeCallbacks();
251 
253  virtual void setMessageTracking(DtRtiMsg& msg);
254 
257  virtual void destroyPackets();
258 
260  virtual void destroyRelConn();
261 
263  virtual void destroyAncillaryRelConn(DtRtiConnection* conn);
264 
266  virtual void destroyAncillaryRelConns();
267 
269  virtual void startAsynchronousReceiveProcessing();
270  virtual void startAsynchronousSendProcessing();
271 
273  virtual void stopAsynchronousReceiveProcessing();
274  virtual void stopAsynchronousSendProcessing();
275 
278  inline DtQueuePacket* getPacket();
279 
282  virtual bool createBestEffortConn();
283 
288  virtual bool queueReceivePacket(DtRtiMsg* rtiMessage, MAKRti::DtTransportType transportType,
289  bool& overflowWarning);
290 
293  virtual void testIoIndicator(const char* label, unsigned int queueLevel,
294  unsigned int& lowWaterLine, unsigned int& highWaterLine, bool& overflowWarning);
295 
296 public:
297 
299  static DtConnectionMgr* create( DtRIDParameters* p, bool isFederate = false,
300  DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
301  DtBoost::shared_ptr<DtRtiAssistantLrcClient>() );
302 
304 #ifdef _WIN32
305  static unsigned long runReceive( void* usr );
306  static unsigned long runSend( void* usr );
307 #else
308  static void* runReceive( void* usr );
309  static void* runSend( void* usr );
310 #endif
311 
312 protected:
313 
315  static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr);
316 
317 protected:
328  bool myNonReflectedList[DtInvalidMsgKind + 1];
329 
330 #ifdef _WIN32
331  HANDLE myReceiveThreadHandle;
332  HANDLE mySendThreadHandle;
333  HANDLE myReceiveWaitEvent;
334  HANDLE* myWaitEvents;
335  HANDLE mySendWaitEvent;
336  unsigned int myNumWaitEvents;
337 #else
338  DtSelectParamWithWrite myWaitEventsParams;
341  int mySendEvent[2];
342  int myRecvEvent[2];
343 #endif
344 
345  float myIoPeriod;
347  unsigned int myMaxQueue;
348  unsigned int myMaxCount;
349 
351  unsigned int mySendPacketCount;
352  unsigned int myReadPacketCount;
353 
360 
362  DtCallbackQueue* myCallbackQueue;
363 
364  DtThreadSafe<bool> myAsynchronousConnectionIsOk;
365 
370 
373 #ifdef _WIN32
374  unsigned int myWaitEvent_BestEffortConn;
375  unsigned int myWaitEvent_PrimaryReliableConn;
376  unsigned int myWaitEvent_AncillaryReliableConnStart;
377  unsigned int myNoBestEffort;
378 #endif
379 
380  unsigned int myIoQueueIndicator;
387 
392 };
393 
394 #endif
395 
virtual void destroyAncillaryRelConn(DtRtiConnection *conn)
Destroy the given ancillary reliable connection.
pthread_t myReceiveThreadHandle
Definition: asyConMgr.h:339
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:380
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:325
float myTickWaitPeriod
Definition: asyConMgr.h:346
DtAsycQueueType * mySendQueue
Exchange queues between federate and IO threads these lists are used in asynchronous mode...
Definition: asyConMgr.h:358
DtNetReadStatus
Definition: connection.h:21
pthread_t mySendThreadHandle
Definition: asyConMgr.h:340
virtual bool processConnectionsInCallback()
unsigned int myReadPacketCount
Definition: asyConMgr.h:352
This class manages the RTI&#39;s start-up configuration using both MTL variables and functions.
Definition: RIDparams.h:87
!DtIFSPEC1516
Definition: fedTimeFactory.h:190
virtual bool doWait(MAKRti::DtTime period)
perform actual wait. Called by wait
unsigned int mySendQueueLowWaterLine
Definition: asyConMgr.h:384
This class represents a network connection with another RTI component.
Definition: connection.h:38
bool myTimeToQuitSending
Definition: asyConMgr.h:318
bool mySendOverflowWarning
Definition: asyConMgr.h:386
bool myAsynchronousProcessMsg
Definition: asyConMgr.h:324
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:319
float myIoPeriod
Definition: asyConMgr.h:345
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:323
TransportationHandle TransportType
Definition: RTItypes13.h:124
Note: no message kind may be &gt; DtInvalidMsgKind This is a limitation imposed by the RTI Msg Header - ...
Definition: rtiMsgKind.h:155
virtual void shutdown()
Request shutdown of communication activities.
unsigned int myReceiveQueueLowWaterLine
Definition: asyConMgr.h:381
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:322
virtual bool flush()
Send buffered messages.
unsigned int mySendPacketCount
Number of packets until time to yield (== max count)
Definition: asyConMgr.h:351
unsigned int myMaxCount
Definition: asyConMgr.h:348
DtThreadSafe< bool > myAsynchronousConnectionIsOk
Definition: asyConMgr.h:364
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:84
virtual void destroyAncillaryRelConns()
Destroy ancillary reliable connections.
DtAsycQueueType * myReceiveQueue
Definition: asyConMgr.h:359
Instances of DtConnectionMgr manage the communication objects that the RTI will use to either communi...
Definition: connectMgr.h:60
virtual void destroyRelConn()
Destroy reliable connection.
DtRtiMsg is the base class for messages between RTI components.
Definition: rtiMsg.h:45
DtHandle DtFederateHandle
Definition: internalTypes.h:29
unsigned int myNextReliableConnToRead
Mechanism to track which reliable connection to fetch packets from when multiple ancillary reliable c...
Definition: asyConMgr.h:369
unsigned int mySendQueueHighWaterLine
Definition: asyConMgr.h:385
MAKRti::DtInetAddr addr
Definition: asyConMgr.h:49
Definition: asyConMgr.h:37
bool myDoDisconnect
Definition: asyConMgr.h:327
unsigned int myMaxQueue
Definition: asyConMgr.h:347
virtual bool createBestEffortConn()
Create best effort connection; Returns true if successful Could be that it already exist in which cas...
virtual int readFileDescriptor(RTI::TransportType transport)
Returns a file descriptor on which data will be present for the given transport type whenever there i...
virtual bool tick()
Receiving.
bool mySendThreadActivated
Definition: asyConMgr.h:320
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:382
#define DT_DLL_LRC
Definition: rtiMsConfig.h:126
bool myReceiveThreadActivated
Definition: asyConMgr.h:321
bool myShouldWaitOnCurrentBundle
This determines whether the send thread should sleep after it attempts to send all packets...
Definition: asyConMgr.h:391
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...
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:383
virtual DtNetReadStatus handleMsg(DtRtiMsg &msg)
Handle this message by either processing it or queuing it if save pending.
bool myMoreToFlush
Definition: asyConMgr.h:326
DtCallbackQueue * myCallbackQueue
A federate ambassador wrapper that queues up federate ambassador calls.
Definition: asyConMgr.h:362
A message that delivers stored callbacks generated by asynchronous thread.
Definition: fedAmbCallbackMsg.h:38
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:338

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)