]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/tls.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Win32 implementation of wxTlsValue<>
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_MSW_TLS_H_
12 #define _WX_MSW_TLS_H_
17 #include "wx/msw/wrapwin.h"
19 // ----------------------------------------------------------------------------
20 // wxTlsKey is a helper class encapsulating a TLS slot
21 // ----------------------------------------------------------------------------
26 // ctor allocates a new key
29 m_slot
= ::TlsAlloc();
30 if ( m_slot
== TLS_OUT_OF_INDEXES
)
31 wxLogError("Creating TLS key failed");
34 // return true if the key was successfully allocated
35 bool IsOk() const { return m_slot
!= TLS_OUT_OF_INDEXES
; }
37 // get the key value, there is no error return
40 return ::TlsGetValue(m_slot
);
43 // change the key value, return true if ok
46 if ( !::TlsSetValue(m_slot
, value
) )
48 wxLogSysError(_("Failed to set TLS value"));
60 if ( !::TlsFree(m_slot
) )
62 wxLogDebug("TlsFree() failed: %08x", ::GetLastError());
70 DECLARE_NO_COPY_CLASS(wxTlsKey
)
73 #endif // _WX_MSW_TLS_H_