File indexing completed on 2025-01-18 09:28:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_POSIX_TSS_PTR_HPP
0012 #define BOOST_ASIO_DETAIL_POSIX_TSS_PTR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_PTHREADS)
0021
0022 #include <pthread.h>
0023 #include <boost/asio/detail/noncopyable.hpp>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029 namespace detail {
0030
0031
0032 BOOST_ASIO_DECL void posix_tss_ptr_create(pthread_key_t& key);
0033
0034 template <typename T>
0035 class posix_tss_ptr
0036 : private noncopyable
0037 {
0038 public:
0039
0040 posix_tss_ptr()
0041 {
0042 posix_tss_ptr_create(tss_key_);
0043 }
0044
0045
0046 ~posix_tss_ptr()
0047 {
0048 ::pthread_key_delete(tss_key_);
0049 }
0050
0051
0052 operator T*() const
0053 {
0054 return static_cast<T*>(::pthread_getspecific(tss_key_));
0055 }
0056
0057
0058 void operator=(T* value)
0059 {
0060 ::pthread_setspecific(tss_key_, value);
0061 }
0062
0063 private:
0064
0065
0066 pthread_key_t tss_key_;
0067 };
0068
0069 }
0070 }
0071 }
0072
0073 #include <boost/asio/detail/pop_options.hpp>
0074
0075 #if defined(BOOST_ASIO_HEADER_ONLY)
0076 # include <boost/asio/detail/impl/posix_tss_ptr.ipp>
0077 #endif
0078
0079 #endif
0080
0081 #endif