]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/tls.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxTLS_TYPE() 
   4 // Author:      Vadim Zeitlin 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  10     Macro to be used for thread-specific variables declarations. 
  12     This macro can be used to define thread-specific variables of the specified 
  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 
  22         ... data which will be different for every thread ... 
  25     static wxTLS_TYPE(PerThreadData) s_threadDataVar; 
  26     #define s_threadData (wxTLS_VALUE(s_threadDataVar)) 
  28     ... use s_threadData as a variable of type PerThreadData ... 
  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. 
  38 #define wxTLS_TYPE(type) compiler-dependent-implementation 
  41     Macro to access thread-specific variables. 
  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. 
  49     As shown in wxTLS_TYPE() example, you may want to @c \#define a symbol 
  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. 
  56 #define wxTLS_VALUE(var) 
  59     Macro to return address of a thread-specific variables. 
  61     This macro is similar to wxTLS_VALUE() except that it always returns a 
  62     pointer to the type of thread-specific variable. 
  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 
  68 #define wxTLS_PTR(var)