]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/tls.h
Added wxPGProperty::SetDefaultValue(v), as a shortcut for SetAttribute(DefaultValue, v)
[wxWidgets.git] / include / wx / os2 / tls.h
CommitLineData
f35f85a9
SN
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
fcc9c05e
SN
11#ifndef _WX_OS2_TLS_H_
12#define _WX_OS2_TLS_H_
f35f85a9
SN
13
14#include "wx/os2/private.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 APIRET rc = ::DosAllocThreadLocalMemory(1, &m_slot);
2c6dbc21
VZ
27 if (rc != NO_ERROR)
28 m_slot = NULL;
f35f85a9
SN
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;
2c6dbc21 44 return true;
f35f85a9
SN
45 }
46
47 // free the key
48 ~wxTlsKey()
49 {
50 if ( IsOk() )
51 ::DosFreeThreadLocalMemory(m_slot);
52 }
53
54private:
55 ULONG* m_slot;
56
c0c133e1 57 wxDECLARE_NO_COPY_CLASS(wxTlsKey);
f35f85a9
SN
58};
59
fcc9c05e 60#endif // _WX_OS2_TLS_H_
f35f85a9 61