MAK RTIspy API Documentation for HLA 1516
 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
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 
165  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 
177  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 
303  virtual void exitServiceCall();
304 
306 #ifdef _WIN32
307  static unsigned long runReceive( void* usr );
308  static unsigned long runSend( void* usr );
309 #else
310  static void* runReceive( void* usr );
311  static void* runSend( void* usr );
312 #endif
313 
314 protected:
315 
317  static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr);
318 
319 protected:
330  bool myNonReflectedList[DtInvalidMsgKind + 1];
331 
332 #ifdef _WIN32
333  HANDLE myReceiveThreadHandle;
334  HANDLE mySendThreadHandle;
335  HANDLE myEvent;
336  HANDLE* myWaitEvents;
337  HANDLE mySendWaitEvent;
338  unsigned int myNumWaitEvents;
339 #else
340  DtSelectParamWithWrite myWaitEventsParams;
343  int mySendEvent[2];
344  int myRecvEvent[2];
345 #endif
346 
347  float myIoPeriod;
349  unsigned int myMaxQueue;
350  unsigned int myMaxCount;
351 
353  unsigned int mySendPacketCount;
354  unsigned int myReadPacketCount;
355 
362 
364  DtCallbackQueue* myCallbackQueue;
365 
366  DtThreadSafe<bool> myAsynchronousConnectionIsOk;
367 
372 
375 #ifdef _WIN32
376  unsigned int myWaitEvent_BestEffortConn;
377  unsigned int myWaitEvent_PrimaryReliableConn;
378  unsigned int myWaitEvent_AncillaryReliableConnStart;
379  unsigned int myNoBestEffort;
380 #endif
381 
382  unsigned int myIoQueueIndicator;
389 
394 };
395 
396 #endif
397 

Document ID: Generated on Mon Jul 9 10:30:41 EDT 2018 from SVN revision 190224
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)