]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/tls.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Pthreads implementation of wxTlsValue<>
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIX_TLS_H_
12 #define _WX_UNIX_TLS_H_
19 // ----------------------------------------------------------------------------
20 // wxTlsKey is a helper class encapsulating the TLS value index
21 // ----------------------------------------------------------------------------
26 // ctor allocates a new key
29 int rc
= pthread_key_create(&m_key
, NULL
);
31 wxLogSysError(_("Creating TLS key failed"), rc
);
34 // return true if the key was successfully allocated
35 bool IsOk() const { return m_key
!= 0; }
37 // get the key value, there is no error return
40 return pthread_getspecific(m_key
);
43 // change the key value, return true if ok
46 int rc
= pthread_setspecific(m_key
, value
);
49 wxLogSysError(_("Failed to set TLS value"));
60 pthread_key_delete(m_key
);
66 DECLARE_NO_COPY_CLASS(wxTlsKey
)
69 #endif // _WX_UNIX_TLS_H_