]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/threadinfo.h
500af5dd9cbf1774a004a60824671ae020fd06ae
[wxWidgets.git] / include / wx / private / threadinfo.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/threadinfo.h
3 // Purpose: declaration of wxThreadSpecificInfo: thread-specific information
4 // Author: Vadim Zeitlin
5 // Created: 2009-07-13
6 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_PRIVATE_THREADINFO_H_
11 #define _WX_PRIVATE_THREADINFO_H_
12
13 #include "wx/defs.h"
14
15 class WXDLLIMPEXP_FWD_BASE wxLog;
16
17 // ----------------------------------------------------------------------------
18 // wxThreadSpecificInfo: contains all thread-specific information used by wx
19 // ----------------------------------------------------------------------------
20
21 // Group all thread-specific information we use (e.g. the active wxLog target)
22 // a in this class to avoid consuming more TLS slots than necessary as there is
23 // only a limited number of them.
24 class wxThreadSpecificInfo
25 {
26 public:
27 // Return this thread's instance.
28 static wxThreadSpecificInfo& Get();
29
30 // the thread-specific logger or NULL if the thread is using the global one
31 // (this is not used for the main thread which always uses the global
32 // logger)
33 wxLog *logger;
34
35 // true if logging is currently disabled for this thread (this is also not
36 // used for the main thread which uses wxLog::ms_doLog)
37 //
38 // NB: we use a counter-intuitive "disabled" flag instead of "enabled" one
39 // because the default, for 0-initialized struct, should be to enable
40 // logging
41 bool loggingDisabled;
42
43 private:
44 wxThreadSpecificInfo() : logger(NULL), loggingDisabled(false) {}
45 };
46
47 #define wxThreadInfo wxThreadSpecificInfo::Get()
48
49 #endif // _WX_PRIVATE_THREADINFO_H_
50