summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/win_global.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/win_global.hpp')
-rw-r--r--3rdparty/asio/include/asio/detail/win_global.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/3rdparty/asio/include/asio/detail/win_global.hpp b/3rdparty/asio/include/asio/detail/win_global.hpp
index 92ebdadfa8b..f77976e21ed 100644
--- a/3rdparty/asio/include/asio/detail/win_global.hpp
+++ b/3rdparty/asio/include/asio/detail/win_global.hpp
@@ -2,7 +2,7 @@
// detail/win_global.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -35,7 +35,7 @@ struct win_global_impl
static win_global_impl instance_;
static static_mutex mutex_;
- static T* ptr_;
+ T* ptr_;
static tss_ptr<T> tss_ptr_;
};
@@ -46,9 +46,6 @@ template <typename T>
static_mutex win_global_impl<T>::mutex_ = ASIO_STATIC_MUTEX_INIT;
template <typename T>
-T* win_global_impl<T>::ptr_ = 0;
-
-template <typename T>
tss_ptr<T> win_global_impl<T>::tss_ptr_;
template <typename T>
@@ -58,8 +55,9 @@ T& win_global()
{
win_global_impl<T>::mutex_.init();
static_mutex::scoped_lock lock(win_global_impl<T>::mutex_);
- win_global_impl<T>::ptr_ = new T;
- win_global_impl<T>::tss_ptr_ = win_global_impl<T>::ptr_;
+ if (win_global_impl<T>::instance_.ptr_ == 0)
+ win_global_impl<T>::instance_.ptr_ = new T;
+ win_global_impl<T>::tss_ptr_ = win_global_impl<T>::instance_.ptr_;
}
return *win_global_impl<T>::tss_ptr_;