ThreadedSocketInitiator.h
Go to the documentation of this file.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, thread_id > 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( double timeout );
00060 void onStop();
00061
00062 void doConnect( const SessionID& s, const Dictionary& d );
00063
00064 void addThread( int s, thread_id t );
00065 void removeThread( int s );
00066 void lock() { Locker l(m_mutex); }
00067 static THREAD_PROC socketThread( void* p );
00068
00069 void getHost( const SessionID&, const Dictionary&, std::string&, short& );
00070
00071 SessionSettings m_settings;
00072 SessionToHostNum m_sessionToHostNum;
00073 time_t m_lastConnect;
00074 int m_reconnectInterval;
00075 bool m_noDelay;
00076 int m_sendBufSize;
00077 int m_rcvBufSize;
00078 bool m_stop;
00079 SocketToThread m_threads;
00080 Mutex m_mutex;
00081 };
00083 }
00084
00085 #endif //FIX_THREADEDSOCKETINITIATOR_H