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 
284 public:
285 
287  static DtConnectionMgr* create( DtRIDParameters* p, bool isFederate = false,
288  DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
289  DtBoost::shared_ptr<DtRtiAssistantLrcClient>() );
290 
292 #ifdef _WIN32
293  static unsigned long runReceive( void* usr );
294  static unsigned long runSend( void* usr );
295 #else
296  static void* runReceive( void* usr );
297  static void* runSend( void* usr );
298 #endif
299 
300 protected:
301 
303  static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr);
304 
305 protected:
316  bool myNonReflectedList[DtInvalidMsgKind + 1];
317 
318 #ifdef _WIN32
319  HANDLE myReceiveThreadHandle;
320  HANDLE mySendThreadHandle;
321  HANDLE myEvent;
322  HANDLE* myWaitEvents;
323  HANDLE mySendWaitEvent;
324  unsigned int myNumWaitEvents;
325 #else
326  DtSelectParamWithWrite myWaitEventsParams;
329  int mySendEvent[2];
330  int myRecvEvent[2];
331 #endif
332 
333  float myIoPeriod;
335  unsigned int myMaxQueue;
336  unsigned int myMaxCount;
337 
339  unsigned int mySendPacketCount;
340  unsigned int myReadPacketCount;
341 
348 
350  DtCallbackQueue* myCallbackQueue;
351 
352  DtThreadSafe<bool> myAsynchronousConnectionIsOk;
353 
358 
361 #ifdef _WIN32
362  unsigned int myWaitEvent_BestEffortConn;
363  unsigned int myWaitEvent_PrimaryReliableConn;
364  unsigned int myWaitEvent_AncillaryReliableConnStart;
365  unsigned int myNoBestEffort;
366 #endif
367 
372 };
373 
374 #endif
375 

Document ID: Generated on Mon Mar 21 09:41:37 EDT 2016 from SVN revision 163228
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)