]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/threadinfo.h
27a71674b0624e2cfddb32036cf44be4ae4bce2d
[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 #if wxUSE_INTL
18 #include "wx/hashset.h"
19 WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual,
20 wxLocaleUntranslatedStrings);
21 #endif
22
23
24 // ----------------------------------------------------------------------------
25 // wxThreadSpecificInfo: contains all thread-specific information used by wx
26 // ----------------------------------------------------------------------------
27
28 // Group all thread-specific information we use (e.g. the active wxLog target)
29 // a in this class to avoid consuming more TLS slots than necessary as there is
30 // only a limited number of them.
31 class wxThreadSpecificInfo
32 {
33 public:
34 // Return this thread's instance.
35 static wxThreadSpecificInfo& Get();
36
37 // the thread-specific logger or NULL if the thread is using the global one
38 // (this is not used for the main thread which always uses the global
39 // logger)
40 wxLog *logger;
41
42 // true if logging is currently disabled for this thread (this is also not
43 // used for the main thread which uses wxLog::ms_doLog)
44 //
45 // NB: we use a counter-intuitive "disabled" flag instead of "enabled" one
46 // because the default, for 0-initialized struct, should be to enable
47 // logging
48 bool loggingDisabled;
49
50 #if wxUSE_INTL
51 // Storage for wxTranslations::GetUntranslatedString()
52 wxLocaleUntranslatedStrings untranslatedStrings;
53 #endif
54
55 #if wxUSE_THREADS
56 // Cleans up storage for the current thread. Should be called when a thread
57 // is being destroyed. If it's not called, the only bad thing that happens
58 // is that the memory is deallocated later, on process termination.
59 static void ThreadCleanUp();
60 #endif
61
62 private:
63 wxThreadSpecificInfo() : logger(NULL), loggingDisabled(false) {}
64 };
65
66 #define wxThreadInfo wxThreadSpecificInfo::Get()
67
68 #endif // _WX_PRIVATE_THREADINFO_H_
69