]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/tls.h
fix warning about hiding the base class LoadFile()
[wxWidgets.git] / include / wx / os2 / tls.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/tls.h
3 // Purpose: OS/2 implementation of wxTlsValue<>
4 // Author: Stefan Neis
5 // Created: 2008-08-30
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Stefan Neis
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_OS2_TLS_H_
12 #define _WX_OS2_TLS_H_
13
14 #include "wx/os2/private.h"
15
16 // ----------------------------------------------------------------------------
17 // wxTlsKey is a helper class encapsulating a TLS slot
18 // ----------------------------------------------------------------------------
19
20 class wxTlsKey
21 {
22 public:
23 // ctor allocates a new key
24 wxTlsKey()
25 {
26 APIRET rc = ::DosAllocThreadLocalMemory(1, &m_slot);
27 if (rc != NO_ERROR)
28 m_slot = NULL;
29 }
30
31 // return true if the key was successfully allocated
32 bool IsOk() const { return m_slot != NULL; }
33
34 // get the key value, there is no error return
35 void *Get() const
36 {
37 return (void *)m_slot;
38 }
39
40 // change the key value, return true if ok
41 bool Set(void *value)
42 {
43 m_slot = (ULONG*)value;
44 return true;
45 }
46
47 // free the key
48 ~wxTlsKey()
49 {
50 if ( IsOk() )
51 ::DosFreeThreadLocalMemory(m_slot);
52 }
53
54 private:
55 ULONG* m_slot;
56
57 DECLARE_NO_COPY_CLASS(wxTlsKey)
58 };
59
60 #endif // _WX_OS2_TLS_H_
61