File indexing completed on 2025-01-18 09:28:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_WIN_TSS_PTR_HPP
0012 #define BOOST_ASIO_DETAIL_WIN_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_WINDOWS)
0021
0022 #include <boost/asio/detail/noncopyable.hpp>
0023 #include <boost/asio/detail/socket_types.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 DWORD win_tss_ptr_create();
0033
0034 template <typename T>
0035 class win_tss_ptr
0036 : private noncopyable
0037 {
0038 public:
0039
0040 win_tss_ptr()
0041 : tss_key_(win_tss_ptr_create())
0042 {
0043 }
0044
0045
0046 ~win_tss_ptr()
0047 {
0048 ::TlsFree(tss_key_);
0049 }
0050
0051
0052 operator T*() const
0053 {
0054 return static_cast<T*>(::TlsGetValue(tss_key_));
0055 }
0056
0057
0058 void operator=(T* value)
0059 {
0060 ::TlsSetValue(tss_key_, value);
0061 }
0062
0063 private:
0064
0065
0066 DWORD 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/win_tss_ptr.ipp>
0077 #endif
0078
0079 #endif
0080
0081 #endif