Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
smp
SerialSection.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_MATH_SMP_SERIALSECTION_H_
36
#define _BLAZE_MATH_SMP_SERIALSECTION_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/math/Exception.h
>
44
#include <
blaze/util/Suffix.h
>
45
46
47
namespace
blaze {
48
49
//=================================================================================================
50
//
51
// CLASS DEFINITION
52
//
53
//=================================================================================================
54
55
//*************************************************************************************************
63
template
<
typename
T >
64
class
SerialSection
65
{
66
public
:
67
//**Constructor*********************************************************************************
70
inline
SerialSection
(
bool
activate );
72
//**********************************************************************************************
73
74
//**Destructor**********************************************************************************
77
inline
~SerialSection
();
79
//**********************************************************************************************
80
81
//**Conversion operator*************************************************************************
84
inline
operator
bool()
const
;
86
//**********************************************************************************************
87
88
private
:
89
//**Member variables****************************************************************************
92
static
bool
active_
;
97
//**********************************************************************************************
98
99
//**Friend declarations*************************************************************************
101
friend
bool
isSerialSectionActive
();
103
//**********************************************************************************************
104
};
105
//*************************************************************************************************
106
107
108
109
110
//=================================================================================================
111
//
112
// DEFINITION AND INITIALIZATION OF THE STATIC MEMBER VARIABLES
113
//
114
//=================================================================================================
115
116
//*************************************************************************************************
118
template
<
typename
T >
119
bool
SerialSection<T>::active_
=
false
;
121
//*************************************************************************************************
122
123
124
125
126
//=================================================================================================
127
//
128
// CONSTRUCTOR
129
//
130
//=================================================================================================
131
132
//*************************************************************************************************
138
template
<
typename
T >
139
inline
SerialSection<T>::SerialSection
(
bool
activate )
140
{
141
if
(
active_
) {
142
BLAZE_THROW_RUNTIME_ERROR
(
"Nested serial sections detected"
);
143
}
144
145
active_
= activate;
146
}
147
//*************************************************************************************************
148
149
150
151
152
//=================================================================================================
153
//
154
// DESTRUCTOR
155
//
156
//=================================================================================================
157
158
//*************************************************************************************************
161
template
<
typename
T >
162
inline
SerialSection<T>::~SerialSection
()
163
{
164
active_
=
false
;
// Resetting the activity flag
165
}
166
//*************************************************************************************************
167
168
169
170
171
//=================================================================================================
172
//
173
// CONVERSION OPERATOR
174
//
175
//=================================================================================================
176
177
//*************************************************************************************************
183
template
<
typename
T >
184
inline
SerialSection<T>::operator
bool()
const
185
{
186
return
active_
;
187
}
188
//*************************************************************************************************
189
190
191
192
193
//=================================================================================================
194
//
195
// GLOBAL FUNCTIONS
196
//
197
//=================================================================================================
198
199
//*************************************************************************************************
202
inline
bool
isSerialSectionActive
();
204
//*************************************************************************************************
205
206
207
//*************************************************************************************************
213
inline
bool
isSerialSectionActive
()
214
{
215
return
SerialSection<int>::active_
;
216
}
217
//*************************************************************************************************
218
219
220
221
222
223
224
225
226
//=================================================================================================
227
//
228
// SERIAL SECTION MACRO
229
//
230
//=================================================================================================
231
232
//*************************************************************************************************
262
#define BLAZE_SERIAL_SECTION \
263
if( blaze::SerialSection<int> BLAZE_JOIN( serialSection, __LINE__ ) = true )
264
//*************************************************************************************************
265
266
}
// namespace blaze
267
268
#endif
Suffix.h
Header file for compile time constraints.
blaze::SerialSection::active_
static bool active_
Activity flag for the serial section.
Definition
SerialSection.h:92
blaze::SerialSection::SerialSection
SerialSection(bool activate)
Constructor for the SerialSection class.
Definition
SerialSection.h:139
blaze::SerialSection::~SerialSection
~SerialSection()
Destructor of the SerialSection class.
Definition
SerialSection.h:162
blaze::isSerialSectionActive
bool isSerialSectionActive()
Returns whether a serial section is active or not.
Definition
SerialSection.h:213
BLAZE_THROW_RUNTIME_ERROR
#define BLAZE_THROW_RUNTIME_ERROR(MESSAGE)
Macro for the emission of a std::runtime_error exception.
Definition
Exception.h:379
Exception.h
Header file for the exception macros of the math module.
Generated by
1.18.0