]>
Commit | Line | Data |
---|---|---|
64a044d5 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/tls.h | |
3 | // Purpose: wxTLS_TYPE() | |
4 | // Author: Vadim Zeitlin | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | Macro to be used for thread-specific variables declarations. | |
11 | ||
12 | This macro can be used to define thread-specific variables of the specified | |
8b73c531 VZ |
13 | @a type. Such variables must be global or static and must be POD, i.e. |
14 | not have any constructors or destructor (even implicitly generated by the | |
15 | compiler due to use of base classes or members which are not POD in a | |
16 | struct). | |
17 | ||
18 | Example of use: | |
64a044d5 VZ |
19 | @code |
20 | struct PerThreadData | |
21 | { | |
22 | ... data which will be different for every thread ... | |
23 | }; | |
24 | ||
8b73c531 VZ |
25 | static wxTLS_TYPE(PerThreadData) s_threadDataVar; |
26 | #define s_threadData (wxTLS_VALUE(s_threadDataVar)) | |
27 | ||
28 | ... use s_threadData as a variable of type PerThreadData ... | |
64a044d5 VZ |
29 | @endcode |
30 | ||
8b73c531 VZ |
31 | Notice that the use of the ugly wxTLS_VALUE() macro is unfortunately |
32 | required if you need to support platforms without native compiler support | |
33 | for thread-specific variables. If you compile your code only on platforms | |
34 | which do have such support (recent versions of GNU C++ compiler, Microsoft | |
35 | Visual C++ and Sun C++ compiler are known to have it), you can avoid it and | |
36 | use the variable directly. | |
37 | */ | |
38 | #define wxTLS_TYPE(type) compiler-dependent-implementation | |
39 | ||
40 | /** | |
41 | Macro to access thread-specific variables. | |
42 | ||
43 | This macro is used to hide the difference in implementation of | |
44 | thread-specific variables under different platforms: they can be of type T | |
45 | used in wxTLS_TYPE() if they are directly supported by the compiler or of | |
46 | type emulating @c T @c *, i.e. a pointer to this type otherwise. This macro | |
47 | always returns an expression of type @c T itself. | |
48 | ||
792255cc | 49 | As shown in wxTLS_TYPE() example, you may want to @c \#define a symbol |
8b73c531 VZ |
50 | wrapping a thread-specific variable with this macro. And, as also explained |
51 | in wxTLS_TYPE() documentation, you may avoid using it entirely if you | |
52 | target only recent compilers. | |
53 | ||
54 | @see wxTLS_PTR() | |
64a044d5 | 55 | */ |
8b73c531 VZ |
56 | #define wxTLS_VALUE(var) |
57 | ||
58 | /** | |
59 | Macro to return address of a thread-specific variables. | |
60 | ||
61 | This macro is similar to wxTLS_VALUE() except that it always returns a | |
62 | pointer to the type of thread-specific variable. | |
64a044d5 | 63 | |
8b73c531 VZ |
64 | Notice that this is not a constant expression even if the macro is defined |
65 | simply as @c &var -- the value returned is still different for every | |
66 | thread. | |
67 | */ | |
68 | #define wxTLS_PTR(var) |