]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/tls.h
e7dc94023e6360189ca9bd4552de28a0aa0c4500
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_
16 #include "wx/msw/wrapwin.h"
18 // ----------------------------------------------------------------------------
19 // wxTlsKey is a helper class encapsulating a TLS slot
20 // ----------------------------------------------------------------------------
25 // ctor allocates a new key
28 m_slot
= ::TlsAlloc();
29 if ( m_slot
== TLS_OUT_OF_INDEXES
)
30 wxLogError("Creating TLS key failed");
33 // return true if the key was successfully allocated
34 bool IsOk() const { return m_slot
!= TLS_OUT_OF_INDEXES
; }
36 // get the key value, there is no error return
39 return ::TlsGetValue(m_slot
);
42 // change the key value, return true if ok
45 if ( !::TlsSetValue(m_slot
, value
) )
47 wxLogSysError(_("Failed to set TLS value"));
59 if ( !::TlsFree(m_slot
) )
61 wxLogDebug("TlsFree() failed: %08x", ::GetLastError());
69 DECLARE_NO_COPY_CLASS(wxTlsKey
)
72 #endif // _WX_MSW_TLS_H_