108 lines
9.2 KiB
HTML
108 lines
9.2 KiB
HTML
<!-- HTML header for doxygen 1.8.7-->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.11"/>
|
|
<title>OnixS C++ CME Market Data Handler: Setting Up Feed Engine</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="onixs-doxygen.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript">
|
|
$(window).scroll(function() {
|
|
if ($(this).scrollTop() > 1)
|
|
{
|
|
$('header').addClass("sticky");
|
|
}
|
|
else
|
|
{
|
|
$('header').removeClass("sticky");
|
|
}
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><a href="http://www.onixs.biz"><img alt="Logo" src="onixs.svg"/></a></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">OnixS C++ CME Market Data Handler
|
|
 <span id="projectnumber">4.3.0</span>
|
|
</div>
|
|
<div id="projectbrief">API documentation</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</header>
|
|
<div id="wrapper">
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.11 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Home</span></a></li>
|
|
<li class="current"><a href="modules.html"><span>Contents</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Setting Up Feed Engine<div class="ingroups"><a class="el" href="group__getting-started.html">Getting Started</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<p>Feed Engine concept encapsulates network-related aspects to let Handler focus on market data processing. It also provides advanced facilities on utilizing system resources used by the Handler to achieve best performance and latency characteristics.</p>
|
|
<p>Previously, all Handler instances were isolated between each other and thus system resources were allocated exactly for particular instance needs. That caused certain inefficiency in terms of resources utilization. For example, each Handler used from one to two threads to manage incoming market data processing. As a result, number of threads used by multiple Handler instances was multiplied by number of those instances and significantly exceeded effective amount of resources needed to solve market data processing task.</p>
|
|
<p>To make things more efficient, concept of Feed Engine was involved. Since recent release Feed Engine machinery used by Handler to receive and process market data. Single instance of Feed Engine can be shared across multiple Handler instances.</p>
|
|
<h1><a class="anchor" id="using-feed-engine"></a>
|
|
Using Feed Engine</h1>
|
|
<p>Feed Engine concept is represented by <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FeedEngine.html" title="Manages processing machinery for market data received from feeds. ">OnixS::CME::MDH::FeedEngine</a> class. Feed Engine events are reported through instance of <a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FeedEngineListener.html">OnixS::CME::MDH::FeedEngineListener</a> class, associated with the Feed Engine instance at constructing stage.</p>
|
|
<p>Following code sample depicts primary aspects of using Feed Engine with two Handler instances:</p>
|
|
<div class="fragment"><div class="line"><span class="comment">// STEP 1: is to set configuration parameters.</span></div><div class="line">FeedEngineSettings feedEngineSettings;</div><div class="line"></div><div class="line">feedEngineSettings.threadsCount(NUMBER_OF_WORKING_THREADS);</div><div class="line"></div><div class="line"><span class="comment">// STEP 2: is to construct shared feed engine.</span></div><div class="line">FeedEngine feedEngine(feedEngineSettings);</div><div class="line"></div><div class="line"><span class="comment">// STEP 3: is to bind feed engine to Handler instances.</span></div><div class="line">handlerForChannel310.bindFeedEngine(feedEngine);</div><div class="line">handlerForChannel311.bindFeedEngine(feedEngine);</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Market data processing is done inside of working threads managed by Feed Engine. Size of internal thread pool is defined by <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FeedEngineSettings.html#aa4f2a73d1364fb9710dda8433a39012b">OnixS::CME::MDH::FeedEngineSettings::threadCount</a> parameter.</dd></dl>
|
|
<h1><a class="anchor" id="feed-engine-events"></a>
|
|
Feed Engine Events</h1>
|
|
<p>All Feed engine events are encapsulated into <a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FeedEngineListener.html">OnixS::CME::MDH::FeedEngineListener</a> class interface. <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FeedEngine.html" title="Manages processing machinery for market data received from feeds. ">OnixS::CME::MDH::FeedEngine</a> class accepts instance of listener upon construction.</p>
|
|
<p>Following table uncovers Feed Engine events:</p>
|
|
<table class="doxtable">
|
|
<tr>
|
|
<th>Event> </th><th>Description </th></tr>
|
|
<tr>
|
|
<td><a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FeedEngineListener.html#a3c5f98c87667ddd93fdbc9820d2389da">OnixS::CME::MDH::FeedEngineListener::onFeedEngineThreadBegin</a> </td><td><p class="starttd">Invoked by Feed Engine's working thread before entering master processing loop.</p>
|
|
<p class="endtd">Event callback is invoked in context of working thread allowing subscriber to perform thread-specific turning like setting affinity or priority for the thread. </p>
|
|
</td></tr>
|
|
<tr>
|
|
<td><a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FeedEngineListener.html#aafba5014f318ce8a54fe437adaf8459c">OnixS::CME::MDH::FeedEngineListener::onFeedEngineThreadEnd</a> </td><td><p class="starttd">Invoked by Feed Engine when working thread is about to end.</p>
|
|
<p class="endtd">Event callback is invoked in context of working thread allowing subscriber to perform thread-specific cleanup like deleting data stored in thread local storage. </p>
|
|
</td></tr>
|
|
<tr>
|
|
<td><a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FeedEngineListener.html#ad989cb350b152bc4e11bcd45819162bb">OnixS::CME::MDH::FeedEngineListener::onFeedEngineThreadIdle</a> </td><td><p class="starttd">Invoked by Feed Engine when working thread is idle.</p>
|
|
<p>At active phase, Feed Engine working thread is running market data processing loop. Working thread may wait for incoming market data using appropriate I/O operation.</p>
|
|
<p>If there were no incoming data detected for a certain time interval (defined by <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FeedEngineSettings.html#ac41ecbc673c5407cdaf0996292261901">OnixS::CME::MDH::FeedEngineSettings::dataWaitTime</a> parameter), working thread raises given event with OnixS::CME::MDH::FeedEngineThreadIdleReasons::DataWaitTimeout as a reason of idle state.</p>
|
|
<p>It may happens that thread misses entering waiting for incoming data because other threads already doing that for all active feeds and there are no other tasks like processing already received market data are available. In such case working threads spins for a certain time (defined by OnixS::CME::MDH::FeedEngineSettings::redundancySpinTime parameter value) while waiting for any pending tasks to be executed. If no pending tasks were found, working thread enters idle state with OnixS::CME::MDH::FeedEngineThreadIdleReasons::Redundant reason.</p>
|
|
<p>Event callback also exposes parameter-variable whose value represents time interval working thread is suggested to spend sleeping to reduce races between working threads for executing pending tasks (data reception, data processing, etc) and thus reduce load onto CPU. Value of parameter can be modified inside the callback body.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>It's not recommended to change sleep time interval when working thread entered idle state after waiting for incoming data to avoid overflow of buffer used for incoming data.</dd></dl>
|
|
<dl class="section warning"><dt>Warning</dt><dd>There's no predictability in firing given event by Feed Engine. Each working thread may wait for incoming data or receive incoming data or process data previously received by that or any other threads. Availability of active tasks to be executed by working threads depends on a lot of factors including number of binded Handler instances, system capacity, number of allocated working threads, clock resolution and other factors. </dd></dl>
|
|
</td></tr>
|
|
</table>
|
|
</div><!-- contents -->
|
|
<!-- HTML footer for doxygen 1.8.7-->
|
|
<!-- start footer part -->
|
|
<footer>
|
|
<hr class="footer"/>
|
|
<address class="footer">
|
|
<small>© <a href="http://www.onixs.biz">Onix Solutions [On<span class="corporate-orange">i</span>x<span class="corporate-orange">S</span>]</a>. All rights reserved.</small>
|
|
</address>
|
|
</footer>
|
|
</div> <!-- wrapper -->
|
|
</body>
|
|
</html>
|