00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIX_THREADEDSOCKETINITIATOR_H
00023 #define FIX_THREADEDSOCKETINITIATOR_H
00024
00025 #ifdef _MSC_VER
00026 #pragma warning( disable : 4503 4355 4786 4290 )
00027 #endif
00028
00029 #include "Initiator.h"
00030 #include "ThreadedSocketConnection.h"
00031 #include <map>
00032
00033 namespace FIX
00034 {
00038
00039 class ThreadedSocketInitiator : public Initiator
00040 {
00041 public:
00042 ThreadedSocketInitiator( Application&, MessageStoreFactory&,
00043 const SessionSettings& ) throw( ConfigError );
00044 ThreadedSocketInitiator( Application&, MessageStoreFactory&,
00045 const SessionSettings&,
00046 LogFactory& ) throw( ConfigError );
00047
00048 virtual ~ThreadedSocketInitiator();
00049
00050 private:
00051 typedef std::map < int, int > SocketToThread;
00052 typedef std::map < SessionID, int > SessionToHostNum;
00053 typedef std::pair < ThreadedSocketInitiator*, ThreadedSocketConnection* > ThreadPair;
00054
00055 void onConfigure( const SessionSettings& ) throw ( ConfigError );
00056 void onInitialize( const SessionSettings& ) throw ( RuntimeError );
00057
00058 void onStart();
00059 bool onPoll();
00060 void onStop();
00061
00062 bool doConnect( const SessionID& s, const Dictionary& d );
00063
00064 void addThread( int s, int t );
00065 void removeThread( int s );
00066 static THREAD_PROC socketThread( void* p );
00067
00068 void getHost( const SessionID&, const Dictionary&, std::string&, short& );
00069
00070 SessionSettings m_settings;
00071 SessionToHostNum m_sessionToHostNum;
00072 time_t m_lastConnect;
00073 int m_reconnectInterval;
00074 bool m_noDelay;
00075 bool m_stop;
00076 SocketToThread m_threads;
00077 Mutex m_mutex;
00078 };
00080 }
00081
00082 #endif //FIX_THREADEDSOCKETINITIATOR_H