Nuria Framework - Core
Core module of the NuriaProject Framework
Main Page
Modules
Classes
Files
File List
All
Classes
Functions
Typedefs
Enumerations
Enumerator
Groups
Framework
Core
threadlocal.hpp
1
/* Copyright (c) 2014, The Nuria Project
2
* This software is provided 'as-is', without any express or implied
3
* warranty. In no event will the authors be held liable for any damages
4
* arising from the use of this software.
5
* Permission is granted to anyone to use this software for any purpose,
6
* including commercial applications, and to alter it and redistribute it
7
* freely, subject to the following restrictions:
8
* 1. The origin of this software must not be misrepresented; you must not
9
* claim that you wrote the original software. If you use this software
10
* in a product, an acknowledgment in the product documentation would be
11
* appreciated but is not required.
12
* 2. Altered source versions must be plainly marked as such, and must not be
13
* misrepresented as being the original software.
14
* 3. This notice may not be removed or altered from any source
15
* distribution.
16
*/
17
18
#ifndef NURIA_THREADLOCAL_HPP
19
#define NURIA_THREADLOCAL_HPP
20
21
#include <QThreadStorage>
22
42
#define NURIA_THREAD_GLOBAL_STATIC(Type, Name) \
43
static Type *Name () { \
44
static QThreadStorage< Type * > storage; \
45
if (!storage.hasLocalData ()) { \
46
storage.setLocalData (new Type); \
47
} \
48
return storage.localData (); \
49
}
50
64
#define NURIA_THREAD_GLOBAL_STATIC_WITH_ARGS(Type, Name, Args) \
65
static Type *Name () { \
66
static QThreadStorage< Type * > storage; \
67
if (!storage.hasLocalData ()) { \
68
storage.setLocalData (new Type Args); \
69
} \
70
return storage.localData (); \
71
}
72
90
#define NURIA_THREAD_GLOBAL_STATIC_WITH_INIT(Type, Name, Method) \
91
static Type *Name () { \
92
static QThreadStorage< Type * > storage; \
93
if (!storage.hasLocalData ()) { \
94
storage.setLocalData (Method ()); \
95
} \
96
return storage.localData (); \
97
}
98
99
#endif // NURIA_THREADLOCAL_HPP
Generated on Sun Jun 29 2014 23:49:06 for Nuria Framework - Core by
1.8.7