OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
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
44namespace OnixS {
45namespace Threading {
46#if defined (_WIN32)
48typedef DWORD ThreadId;
49#else
51typedef pthread_t ThreadId;
52#endif
53
55enum { InfiniteTimeout = -1 };
56
59{
60public:
61
63 ItemBase() : next_() {}
64
67
69 ItemBase * next() const
70 {
71 return next_;
72 }
73
75 void setNext(ItemBase * nextNode)
76 {
77 next_ = nextNode;
78 }
79
81 virtual void process() = 0;
82
83private:
84
85 // The pointer to the next item.
86 ItemBase * volatile next_;
87};
88
90
94{
95public:
96
99
101 virtual ItemBase * alloc() = 0;
102
104 virtual void free(ItemBase * element) const
105 {
106 delete element;
107 }
108};
109
110}
111}
#define ONIXS_FIXENGINE_API
Definition ABI.h:45
#define ONIXS_FIXENGINE_DEFAULT
Definition Compiler.h:194
The base class for custom items which can be stored in thread-safe containers.
Definition Definitions.h:59
void setNext(ItemBase *nextNode)
Sets the next item.
Definition Definitions.h:75
virtual void process()=0
Performs a required processing of the item.
ItemBase()
Initializes the instance.
Definition Definitions.h:63
ItemBase * next() const
Returns the next item.
Definition Definitions.h:69
virtual ~ItemBase() ONIXS_FIXENGINE_DEFAULT
Destructs the instance.
The base class for a custom pool allocator to provide a strategy to create/destroy items for the thre...
Definition Definitions.h:94
virtual ~PoolAllocatorBase() ONIXS_FIXENGINE_DEFAULT
Destructs the instance.
virtual ItemBase * alloc()=0
A strategy to create an item.
virtual void free(ItemBase *element) const
A strategy to destroy an item.
PtrTraits< ItemBase >::UniquePtr ItemBaseUniquePtr
Definition Definitions.h:89
pthread_t ThreadId
Type alias for thread identifier.
Definition Definitions.h:51
std::auto_ptr< T > UniquePtr
Definition Definitions.h:32