OnixS C++ FIX Engine  4.10.1
API Documentation
Definitions.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 
22 #if defined (_WIN32) // The Windows platform.
23 
24 #if !defined (STRICT)
25 #define STRICT
26 #endif
27 
28 #if !defined (WIN32_LEAN_AND_MEAN)
29 #define WIN32_LEAN_AND_MEAN
30 #endif
31 
32 #include <Windows.h>
33 
34 #else // The Linux platform.
35 
36 #include <pthread.h>
37 
38 #endif // The Platform Selector.
39 
40 #include <OnixS/FIXEngine/ABI.h>
43 
44 namespace OnixS {
45 namespace Threading {
46 #if defined (_WIN32)
47 /// Type alias for the thread identifier.
48 typedef DWORD ThreadId;
49 #else
50 /// Type alias for thread identifier.
51 typedef pthread_t ThreadId;
52 #endif
53 
54 /// The infinite timeout value.
55 enum { InfiniteTimeout = -1 };
56 
57 /// The base class for custom items which can be stored in thread-safe containers.
59 {
60 public:
61 
62  /// Initializes the instance.
63  ItemBase() : next_() {}
64 
65  /// Destructs the instance.
67 
68  /// Returns the next item.
69  ItemBase * next() const
70  {
71  return next_;
72  }
73 
74  /// Sets the next item.
75  void setNext(ItemBase * nextNode)
76  {
77  next_ = nextNode;
78  }
79 
80  /// Performs a required processing of the item.
81  virtual void process() = 0;
82 
83 private:
84 
85  // The pointer to the next item.
86  ItemBase * volatile next_;
87 };
88 
90 
91 /// The base class for a custom pool allocator to provide
92 /// a strategy to create/destroy items for the thread-safe pool.
94 {
95 public:
96 
97  /// Destructs the instance.
99 
100  /// A strategy to create an item.
101  virtual ItemBase * alloc() = 0;
102 
103  /// A strategy to destroy an item.
104  virtual void free(ItemBase * element) const
105  {
106  delete element;
107  }
108 };
109 
110 }
111 }
virtual void free(ItemBase *element) const
A strategy to destroy an item.
Definition: Definitions.h:104
PtrTraits< ItemBase >::UniquePtr ItemBaseUniquePtr
Definition: Definitions.h:89
#define ONIXS_FIXENGINE_DEFAULT
Definition: Compiler.h:176
ItemBase * next() const
Returns the next item.
Definition: Definitions.h:69
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
pthread_t ThreadId
Type alias for thread identifier.
Definition: Definitions.h:51
The base class for a custom pool allocator to provide a strategy to create/destroy items for the thre...
Definition: Definitions.h:93
The base class for custom items which can be stored in thread-safe containers.
Definition: Definitions.h:58
ItemBase()
Initializes the instance.
Definition: Definitions.h:63
std::auto_ptr< T > UniquePtr
Definition: Definitions.h:32
void setNext(ItemBase *nextNode)
Sets the next item.
Definition: Definitions.h:75