ThreadedSocketInitiator.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef FIX_THREADEDSOCKETINITIATOR_H
23 #define FIX_THREADEDSOCKETINITIATOR_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "Initiator.h"
31 #include <map>
32 
33 namespace FIX
34 {
38 class ThreadedSocketInitiator : public Initiator
40 {
41 public:
42  ThreadedSocketInitiator( Application&, MessageStoreFactory&,
43  const SessionSettings& ) throw( ConfigError );
44  ThreadedSocketInitiator( Application&, MessageStoreFactory&,
45  const SessionSettings&,
46  LogFactory& ) throw( ConfigError );
47 
48  virtual ~ThreadedSocketInitiator();
49 
50 private:
51  typedef std::map < int, thread_id > SocketToThread;
52  typedef std::map < SessionID, int > SessionToHostNum;
53  typedef std::pair < ThreadedSocketInitiator*, ThreadedSocketConnection* > ThreadPair;
54 
55  void onConfigure( const SessionSettings& ) throw ( ConfigError );
56  void onInitialize( const SessionSettings& ) throw ( RuntimeError );
57 
58  void onStart();
59  bool onPoll( double timeout );
60  void onStop();
61 
62  void doConnect( const SessionID& s, const Dictionary& d );
63 
64  void addThread( int s, thread_id t );
65  void removeThread( int s );
66  void lock() { Locker l(m_mutex); }
67  static THREAD_PROC socketThread( void* p );
68 
69  void getHost( const SessionID&, const Dictionary&, std::string&, short& );
70 
72  SessionToHostNum m_sessionToHostNum;
73  time_t m_lastConnect;
75  bool m_noDelay;
78  SocketToThread m_threads;
80 };
82 }
83 
84 #endif //FIX_THREADEDSOCKETINITIATOR_H
void getHost(const SessionID &, const Dictionary &, std::string &, short &)
std::pair< ThreadedSocketInitiator *, ThreadedSocketConnection *> ThreadPair
std::map< int, thread_id > SocketToThread
void onStop()
Implemented to stop a running initiator.
bool onPoll(double timeout)
Implemented to connect and poll for events.
ThreadedSocketInitiator(Application &, MessageStoreFactory &, const SessionSettings &)
static THREAD_PROC socketThread(void *p)
Definition: Acceptor.cpp:34
Application encountered serious error during runtime
Definition: Exceptions.h:94
Application is not configured correctly
Definition: Exceptions.h:87
Locks/Unlocks a mutex using RAII.
Definition: Mutex.h:95
void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Container for setting dictionaries mapped to sessions.
void onInitialize(const SessionSettings &)
Implemented to initialize initiator.
Portable implementation of a mutex.
Definition: Mutex.h:30
void onStart()
Implemented to start connecting to targets.
std::map< SessionID, int > SessionToHostNum
pthread_t thread_id
Definition: Utility.h:164
For storage and retrieval of key/value pairs.
Definition: Dictionary.h:36
void doConnect(const SessionID &s, const Dictionary &d)
Implemented to connect a session to its target.
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30
#define THREAD_PROC
Definition: Utility.h:158

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001