OnixS C++ SGX Titan ITCH Market Data Handler  1.2.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 
20 #include "FeedEngineImpl.h"
21 
22 #include <system/Thread.h>
23 
24 #include <boost/foreach.hpp>
25 
26 ONIXS_HANDLER_NAMESPACE_BEGIN
27 
28 using namespace std;
29 
30 FeedEngineImpl::FeedEngineImpl(const FeedEngineSettings & settings, HANDLER_NAMESPACE::FeedEngineListener* listener, FeedEngine* publicFeedEngine)
31  : settings_(settings)
32  , listener_(listener)
33  , publicFeedEngine_(publicFeedEngine)
34 {
35  System::Thread::CpuIndexes cpuIndexes;
36  settings.threadAffinity().copyTo(cpuIndexes);
37 
38  HandlerCore::MarketData::FE::FeedEngineSettings feSettings;
39 
40  BOOST_FOREACH(size_t cpuIndex, cpuIndexes)
41  {
42  feSettings.threadAffinity().cpus().insert(static_cast<HandlerCore::MarketData::FE::CpuIndex>(cpuIndex));
43  }
44 
45  feSettings.threadCount(settings.threadCount());
46  feSettings.watch(HandlerCore::MarketData::FE::UtcWatch::service());
47  feSettings.dataWaitTime(settings.dataWaitTime());
48  feSettings.spinBeforeIdleTime(settings.spinBeforeIdleTime());
49  feSettings.socketBufferSize(settings.socketBufferSize());
50 
51  feedEngine_.reset(new HandlerCore::MarketData::FE::MultithreadedFeedEngine(feSettings, this));
52 }
53 
55 {
56 }
57 
59 {
60  feedEngine_->start();
61 }
62 
63 void FeedEngineImpl::onFeedEngineThreadBegin()
64 {
65  if (listener_)
66  listener_->onFeedEngineThreadBegin(*publicFeedEngine_);
67 }
68 
69 void FeedEngineImpl::onFeedEngineThreadEnd()
70 {
71  if (listener_)
72  listener_->onFeedEngineThreadEnd(*publicFeedEngine_);
73 }
74 
75 void FeedEngineImpl::onFeedEngineThreadIdle(HandlerCore::MarketData::FE::FeedEngineThreadIdle::Reason reason, UInt32& timeout)
76 {
77  if (listener_)
78  listener_->onFeedEngineThreadIdle(*publicFeedEngine_, static_cast<HANDLER_NAMESPACE::FeedEngineThreadIdle::Reason>(reason), timeout);
79 }
80 
81 ONIXS_HANDLER_NAMESPACE_END
82 
virtual void onFeedEngineThreadBegin(const FeedEngine &)
Definition: FeedEngine.h:226
STL namespace.
virtual void onFeedEngineThreadEnd(const FeedEngine &)
Definition: FeedEngine.h:233
void copyTo(CpuIndexes &) const
Copies set into another set.
const ThreadAffinity & threadAffinity() const
Definition: FeedEngine.h:105
virtual void onFeedEngineThreadIdle(const FeedEngine &, FeedEngineThreadIdle::Reason, UInt32 &)
Definition: FeedEngine.h:248
Collection of settings affecting Feed Engine behavior.
Definition: FeedEngine.h:78
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:254