2008-08-30 21:55:09 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/os2/tls.h
|
|
|
|
// Purpose: OS/2 implementation of wxTlsValue<>
|
|
|
|
// Author: Stefan Neis
|
|
|
|
// Created: 2008-08-30
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2008 Stefan Neis
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-10-07 22:22:19 +00:00
|
|
|
#ifndef _WX_OS2_TLS_H_
|
|
|
|
#define _WX_OS2_TLS_H_
|
2008-08-30 21:55:09 +00:00
|
|
|
|
|
|
|
#include "wx/os2/private.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxTlsKey is a helper class encapsulating a TLS slot
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxTlsKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctor allocates a new key
|
|
|
|
wxTlsKey()
|
|
|
|
{
|
|
|
|
APIRET rc = ::DosAllocThreadLocalMemory(1, &m_slot);
|
2008-08-30 22:01:20 +00:00
|
|
|
if (rc != NO_ERROR)
|
|
|
|
m_slot = NULL;
|
2008-08-30 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return true if the key was successfully allocated
|
|
|
|
bool IsOk() const { return m_slot != NULL; }
|
|
|
|
|
|
|
|
// get the key value, there is no error return
|
|
|
|
void *Get() const
|
|
|
|
{
|
|
|
|
return (void *)m_slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
// change the key value, return true if ok
|
|
|
|
bool Set(void *value)
|
|
|
|
{
|
|
|
|
m_slot = (ULONG*)value;
|
2008-08-30 22:01:20 +00:00
|
|
|
return true;
|
2008-08-30 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// free the key
|
|
|
|
~wxTlsKey()
|
|
|
|
{
|
|
|
|
if ( IsOk() )
|
|
|
|
::DosFreeThreadLocalMemory(m_slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ULONG* m_slot;
|
|
|
|
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxTlsKey);
|
2008-08-30 21:55:09 +00:00
|
|
|
};
|
|
|
|
|
2008-10-07 22:22:19 +00:00
|
|
|
#endif // _WX_OS2_TLS_H_
|
2008-08-30 21:55:09 +00:00
|
|
|
|