OnixS C++ FIX Engine  4.10.1
API Documentation
TcpStandardStack.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 #pragma once
20 
23 
24 #include <cassert>
25 
26 namespace OnixS {
27 namespace FIX {
28 class ReactorOperator;
29 namespace TCPStandard {
30 
31 /**
32  * A high-level wrapper over the TCP standard stack.
33  */
35 {
36 public:
37  /**
38  * Allocates a TCP stack.
39  */
40  Stack();
41 
42 #ifdef ONIXS_FIXENGINE_CXX11
43  Stack(const Stack &) = delete;
44  Stack(Stack &&) = delete;
45 
46  Stack & operator=(const Stack &) = delete;
47  Stack & operator=(Stack &&) = delete;
48 #endif
49 
50  ~Stack();
51 
52  /**
53  * Processes events on a stack and performs the necessary handling.
54  *
55  * These events include transmit and receive events raised by the hardware,
56  * and also software events such as TCP and FIX protocol timers.
57  *
58  * \warning The event dispatching should be performed from the same thread that created the stack.
59  */
60  void dispatchEvents() ONIXS_FIXENGINE_OVERRIDE {
61  // The TCPStandard middleware is NOT thread-safe.
62  // Therefore, the event dispatching should be performed from the same thread that created the stack.
63 
64  assert(threadId() == Threading::ThisThread::id() && "should be performed from the same thread that created the stack");
65 
66  dispatchEventsImpl();
67  }
68 
69  /**
70  * \return a boolean value indicating whether a stack is quiescent.
71  *
72  * This can be used to ensure that all connections have been closed gracefully before the destroying of a stack
73  * (or exiting the application). The destroying of a stack while it is not quiescent is permitted by the API,
74  * but when doing so there is no guarantee that sent data has been acknowledged by the peer or even transmitted,
75  * and there is the possibility that peers' connections will be reset.
76  */
77  bool isQuiescent() const ONIXS_FIXENGINE_OVERRIDE {
78  assert(threadId() == Threading::ThisThread::id() && "should be performed from the same thread that created the stack");
79 
80  return isQuiescentImpl();
81  }
82 
83  /**
84  * \return the ID of the thread that created the stack.
85  */
86  Threading::ThreadId threadId() const ONIXS_FIXENGINE_OVERRIDE {
87  return threadId_;
88  }
89 
90  ReactorType::Enum type() const ONIXS_FIXENGINE_OVERRIDE {
92  }
93 
94 private:
95  void dispatchEventsImpl();
96 
97  bool isQuiescentImpl() const;
98 
99  class Impl;
100  Impl * const impl_;
101 
102  Threading::ThreadId const threadId_;
103 
104 #ifndef ONIXS_FIXENGINE_CXX11
105  Stack(const Stack &);
106  Stack & operator=(const Stack &);
107 #endif
108 
109  friend class FIX::ReactorOperator;
110 };
111 
112 }}}
Threading::ThreadId threadId() const ONIXS_FIXENGINE_OVERRIDE
A high-level wrapper over the TCP standard stack.
ReactorType::Enum type() const ONIXS_FIXENGINE_OVERRIDE
void dispatchEvents() ONIXS_FIXENGINE_OVERRIDE
Processes events on a stack and performs the necessary handling.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
pthread_t ThreadId
Type alias for thread identifier.
Definition: Definitions.h:51
static ThreadId id()
Gets the platform identifier for the current thread.
bool isQuiescent() const ONIXS_FIXENGINE_OVERRIDE
The session&#39;s network stack reactor interface.
The standard TCP reactor.