Files
externals/linux/doc/Onixs.CME.4.8.0/html/group__feed-engine.html

109 lines
9.5 KiB
HTML

<!-- HTML header for doxygen 1.8.11-->
<!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
&#160;<span id="projectnumber">4.8.0.10</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>
<li><a href="files.html"><span>Files</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>The Feed Engine concept encapsulates network-related aspects to let the 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, there were no shared services between the Handler instances. Thus, system resources were allocated exactly for and by a particular instance. That caused certain inefficiency regarding resources utilization. For example, each Handler instance used from one to two threads to manage incoming market data processing. As a result, the number of threads used by multiple Handler instances was multiplied by the number of those instances and significantly exceeded the effective amount of resources required to solve the market data processing task.</p>
<p>The concept of the Feed Engine was involved to make things more efficient. The Feed Engine machinery is used by the Handler to receive and process market data starting from the recent major release. Multiple Handler instances can share a single instance of the Feed Engine.</p>
<h1><a class="anchor" id="using-feed-engine"></a>
Using Feed Engine</h1>
<p>The <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 represents the Feed Engine concept. Feed Engine events are reported through an instance of the <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>The following code sample depicts primary aspects of using the 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 the Feed Engine. A size of the internal thread pool is defined by the <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 an instance of listener upon construction.</p>
<p>The following table uncovers Feed Engine events:</p>
<table class="doxtable">
<tr>
<th>Event&gt; </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 the Feed Engine working thread before entering a master processing loop.</p>
<p class="endtd">Event callback is invoked in the context of working thread allowing the 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">The given event callback is invoked in the context of the working thread allowing the 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 the Feed Engine when the working thread is idle.</p>
<p>At an active phase, the Feed Engine working thread is running a market data processing loop. The working thread may wait for incoming market data using an appropriate I/O operation.</p>
<p>A working thread raises the given event if there was no incoming data detected for a certain time interval (defined by the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FeedEngineSettings.html#ac41ecbc673c5407cdaf0996292261901">OnixS::CME::MDH::FeedEngineSettings::dataWaitTime</a> parameter). The OnixS::CME::MDH::FeedEngineThreadIdleReasons::DataWaitTimeout is passed as a reason of the idle state.</p>
<p>It may happen that a thread misses entering waiting for incoming data because other threads have already been doing that for all active feeds, and there are no other tasks like the processing already received market data. In such case, the working threads spins for a certain time (defined by the OnixS::CME::MDH::FeedEngineSettings::redundancySpinTime parameter value) while waiting for any pending tasks to be executed. If no pending tasks were found, the working thread enters an idle state with the OnixS::CME::MDH::FeedEngineThreadIdleReasons::Redundant reason.</p>
<p>The given event callback also exposes a parameter-variable which value represents the time interval the working thread is suggested to spend sleeping to reduce races between working threads for executing pending tasks (data reception, data processing, etc.) and thus to reduce a load onto CPU. The parameter value can be modified inside the callback body.</p>
<dl class="section note"><dt>Note</dt><dd>It's not recommended to change the sleep time interval when the working thread entered idle state after waiting for incoming data to avoid overflow of a buffer used for incoming data.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>There's no predictability in firing the given event by the 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, which are executed by the working threads, depends on many factors including some bound Handler instances, system capacity, and a number of allocated working threads, clock resolution and other factors. </dd></dl>
</td></tr>
</table>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.11-->
<!-- start footer part -->
<footer>
<hr class="footer"/>
<address class="footer">
<small>&copy; <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>