wxWidgets/include/wx/unix/tls.h
Vadim Zeitlin 3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00

66 lines
1.7 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/tls.h
// Purpose: Pthreads implementation of wxTlsValue<>
// Author: Vadim Zeitlin
// Created: 2008-08-08
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_TLS_H_
#define _WX_UNIX_TLS_H_
#include <pthread.h>
// ----------------------------------------------------------------------------
// wxTlsKey is a helper class encapsulating the TLS value index
// ----------------------------------------------------------------------------
class wxTlsKey
{
public:
// ctor allocates a new key and possibly registering a destructor function
// for it
wxTlsKey(wxTlsDestructorFunction destructor)
{
m_destructor = destructor;
if ( pthread_key_create(&m_key, destructor) != 0 )
m_key = 0;
}
// return true if the key was successfully allocated
bool IsOk() const { return m_key != 0; }
// get the key value, there is no error return
void *Get() const
{
return pthread_getspecific(m_key);
}
// change the key value, return true if ok
bool Set(void *value)
{
void *old = Get();
if ( old )
m_destructor(old);
return pthread_setspecific(m_key, value) == 0;
}
// free the key
~wxTlsKey()
{
if ( IsOk() )
pthread_key_delete(m_key);
}
private:
wxTlsDestructorFunction m_destructor;
pthread_key_t m_key;
wxDECLARE_NO_COPY_CLASS(wxTlsKey);
};
#endif // _WX_UNIX_TLS_H_