]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/tls.h
made wxHeaderColumnBase dtor virtual to avoid gcc warnings
[wxWidgets.git] / include / wx / msw / tls.h
CommitLineData
64a044d5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/unix/tls.h
3// Purpose: Win32 implementation of wxTlsValue<>
4// Author: Vadim Zeitlin
5// Created: 2008-08-08
6// RCS-ID: $Id$
7// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_MSW_TLS_H_
12#define _WX_MSW_TLS_H_
13
64a044d5
VZ
14#include "wx/msw/wrapwin.h"
15
16// ----------------------------------------------------------------------------
17// wxTlsKey is a helper class encapsulating a TLS slot
18// ----------------------------------------------------------------------------
19
20class wxTlsKey
21{
22public:
23 // ctor allocates a new key
24 wxTlsKey()
25 {
26 m_slot = ::TlsAlloc();
64a044d5
VZ
27 }
28
29 // return true if the key was successfully allocated
30 bool IsOk() const { return m_slot != TLS_OUT_OF_INDEXES; }
31
32 // get the key value, there is no error return
33 void *Get() const
34 {
35 return ::TlsGetValue(m_slot);
36 }
37
38 // change the key value, return true if ok
39 bool Set(void *value)
40 {
8b73c531 41 return ::TlsSetValue(m_slot, value) != 0;
64a044d5
VZ
42 }
43
44 // free the key
45 ~wxTlsKey()
46 {
47 if ( IsOk() )
8b73c531 48 ::TlsFree(m_slot);
64a044d5
VZ
49 }
50
51private:
52 DWORD m_slot;
53
54 DECLARE_NO_COPY_CLASS(wxTlsKey)
55};
56
57#endif // _WX_MSW_TLS_H_
58