OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.0
API Documentation
TcpDirectStack.h
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 #pragma once
21 
25 
26 #include <cassert>
27 
28 namespace OnixS {
29 namespace CME {
30 namespace iLink3 {
31 
32 /**
33 * A high-level wrapper over the TCPDirect network stack.
34 */
36 {
37 public:
38  /** Allocates a stack with the supplied attributes.
39  *
40  * \param attr A set of properties to apply to the stack.
41  *
42  * A stack binds to a single network interface, specified by the `interface` attribute in @p attr.
43  *
44  * Relevant attributes to set in @p attr are those in the `zf_stack`,
45  * `zf_pool` and `zf_vi` categories described in the attributes documentation.
46  *
47  * \throws std::bad_alloc Out of memory. N.B. TCPDirect API requires huge pages.
48  * \throws std::runtime_error the TCPDirect library reported an error, see the error text.
49  * \throws std::exception System call reported an error, see the error text.
50  */
51  explicit TcpDirectStack(const TcpDirectAttr & attr);
52 
53 # if defined(ONIXS_ILINK3_CXX11)
54  TcpDirectStack(const TcpDirectStack &) = delete;
55  TcpDirectStack & operator=(const TcpDirectStack &) = delete;
56  TcpDirectStack(TcpDirectStack &&) = delete;
57  TcpDirectStack & operator=(TcpDirectStack &&) = delete;
58 #endif
59 
61 
62  /**
63  * This function processes events on a stack and performs the necessary handling.
64  *
65  * These events, including transmit and receive events raised by the hardware,
66  * and also software events such as TCP and FIXP timers.
67  *
68  * Please see the "Stack polling" section in the TCPDirect User Guide for further information.
69  */
71  assert(workingThreadId() == Threading::ThisThread::id());
72  dispatchEventsImpl();
73  }
74 
75  /** \return a boolean value indicating whether a stack is quiescent.
76  *
77  * This can be used to ensure that all connections have been closed gracefully before destroying a stack
78  * (or exiting the application). Destroying a stack while it is not quiescent is permitted by the API,
79  * but when doing so there is no guarantee that sent data has been acknowledged by the peer or even transmitted,
80  * and there is the possibility that peers' connections will be reset.
81  *
82  * \note When using the Windows TCPDirect emulator, destroying a stack while it is not quiescent may cause a memory leak.
83  */
85  assert(workingThreadId() == Threading::ThisThread::id());
86  return isQuiescentImpl();
87  }
88 
89  /// \return The Id of the thread that created the stack.
91  return workingThreadId_;
92  }
93 
96  }
97 
98 private:
99  void dispatchEventsImpl() ONIXS_ILINK3_NOTHROW;
100 
101  bool isQuiescentImpl() const ONIXS_ILINK3_NOTHROW;
102 
103  class Impl;
104  Impl * const impl_;
105 
106  Threading::ThreadId const workingThreadId_;
107 
108 # if !defined(ONIXS_ILINK3_CXX11)
110  TcpDirectStack & operator=(const TcpDirectStack &);
111 #endif
112 
113  friend class SessionImpl;
114 };
115 
116 }
117 }
118 }
A high-level wrapper over the TCPDirect network stack.
Session&#39;s network stack reactor interface.
#define ONIXS_ILINK3_OVERRIDE
Definition: Compiler.h:180
void dispatchEvents() noexceptoverride
This function processes events on a stack and performs the necessary handling.
ReactorType::Enum type() const noexceptoverride
Definition: Defines.h:40
pthread_t ThreadId
Type alias for thread identifier.
Definition: Definitions.h:34
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:175
#define ONIXS_ILINK3_FINAL
Definition: Compiler.h:181
bool isQuiescent() const noexceptoverride
Solarflare TCPDirect reactor.
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:176
Threading::ThreadId workingThreadId() const noexceptoverride
TCPDirect Attributes to pass configuration details (a wrapper around the zf_attr struct).
Definition: TcpDirectAttr.h:44