OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
FeedEngineImpl.cpp
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 #include <boost/current_function.hpp>
20 
21 #include <system/Thread.h>
22 
23 #include <OnixS/HandlerCore/FeedEngine/MultithreadedFeedEngine.h>
24 #include <OnixS/HandlerCore/FeedEngine/MultithreadedFeedEngineEfVi.h>
25 
26 #include "FeedEngineImpl.h"
27 
28 #include <boost/foreach.hpp>
29 
30 namespace OnixS {
31 namespace Eurex {
32 namespace MarketData {
33 
34 
36  : settings_(settings)
37  , listener_(listener)
38  , publicFeedEngine_(publicFeedEngine)
39 {
40  System::Thread::CpuIndexes cpuIndexes;
41  settings.threadAffinity().copyTo(cpuIndexes);
42 
43  HandlerCore::MarketData::FE::FeedEngineSettings feSettings;
44 
45  BOOST_FOREACH(size_t cpuIndex, cpuIndexes)
46  {
47  feSettings.threadAffinity().cpus().insert(static_cast<HandlerCore::MarketData::FE::CpuIndex>(cpuIndex));
48  }
49 
50  feSettings.threadCount(settings.threadCount());
51  feSettings.watch(HandlerCore::MarketData::FE::UtcWatch::service());
52  feSettings.dataWaitTime(settings.dataWaitTime());
53  feSettings.spinBeforeIdleTime(settings.spinBeforeIdleTime());
54  feSettings.socketBufferSize(settings.socketBufferSize());
55 
56  const FeedEngineMode::Enum mode = settings.mode();
57 
58  if (mode == FeedEngineMode::Select)
59  {
60  feedEngine_.reset(new HandlerCore::MarketData::FE::MultithreadedFeedEngine(feSettings, this));
61  }
62  else if (mode == FeedEngineMode::EfVi)
63  {
64  feedEngine_.reset(new HandlerCore::MarketData::FE::MultithreadedFeedEngineEfVi(feSettings, this));
65  }
66  else
67  {
68  std::stringstream ss;
69  ss << "Unable to create FeedEngine, unsupported mode: " << FeedEngineMode::toString(mode);
70 
71  throw BadArgumentException(BOOST_CURRENT_FUNCTION, ss.str());
72  }
73 }
74 
76 {
77 }
78 
80 {
81  BOOST_ASSERT(feedEngine_);
82 
83  feedEngine_->start();
84 }
85 
86 std::string FeedEngineImpl::info() const
87 {
88  std::string result = "";
89 
90  feedEngine_->info(result);
91 
92  return result;
93 }
94 
96 {
97  return settings_;
98 }
99 
100 void FeedEngineImpl::onFeedEngineThreadBegin()
101 {
102  BOOST_ASSERT(publicFeedEngine_);
103 
104  if (listener_)
105  listener_->onFeedEngineThreadBegin(*publicFeedEngine_);
106 }
107 
108 void FeedEngineImpl::onFeedEngineThreadEnd()
109 {
110  BOOST_ASSERT(publicFeedEngine_);
111 
112  if (listener_)
113  listener_->onFeedEngineThreadEnd(*publicFeedEngine_);
114 }
115 
116 void FeedEngineImpl::onFeedEngineThreadIdle(HandlerCore::MarketData::FE::FeedEngineThreadIdle::Reason reason, UInt32& timeout)
117 {
118  BOOST_ASSERT(publicFeedEngine_);
119 
120  if (listener_)
121  listener_->onFeedEngineThreadIdle(
122  *publicFeedEngine_,
123  static_cast<Eurex::MarketData::FeedEngineThreadIdle::Reason>(reason),
124  timeout);
125 }
126 
127 }}}
128 
virtual void onFeedEngineThreadBegin(const FeedEngine &)
Definition: FeedEngine.h:256
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
Solarflare ef_vi-based engine.
Definition: FeedEngine.h:89
FeedEngineMode::Enum mode() const
Definition: FeedEngine.h:116
unsigned int UInt32
Definition: Numeric.h:41
virtual void onFeedEngineThreadEnd(const FeedEngine &)
Definition: FeedEngine.h:263
Definition: Defines.h:30
const FeedEngineSettings & settings() const
FeedEngineImpl(const FeedEngineSettings &settings, Eurex::MarketData::FeedEngineListener *listener, Eurex::MarketData::FeedEngine *publicFeedEngine)
Initialize new instance.
virtual ~FeedEngineImpl()
Finalize instance.
static std::string toString(FeedEngineMode::Enum value)
Returns the string representation.
const ThreadAffinity & threadAffinity() const
Definition: FeedEngine.h:133
Collection of settings affecting Feed Engine behavior.
Definition: FeedEngine.h:97
void copyTo(CpuIndexes &) const
Copies set into another set.
virtual void onFeedEngineThreadIdle(const FeedEngine &, FeedEngineThreadIdle::Reason, UInt32 &)
Definition: FeedEngine.h:278