summaryrefslogtreecommitdiff
path: root/boost/libs/thread
diff options
context:
space:
mode:
Diffstat (limited to 'boost/libs/thread')
-rw-r--r--boost/libs/thread/build/Jamfile.v2322
-rw-r--r--boost/libs/thread/build/has_atomic_flag_lockfree_test.cpp13
-rw-r--r--boost/libs/thread/src/future.cpp64
-rw-r--r--boost/libs/thread/src/pthread/once.cpp83
-rw-r--r--boost/libs/thread/src/pthread/once_atomic.cpp90
-rw-r--r--boost/libs/thread/src/pthread/thread.cpp846
-rw-r--r--boost/libs/thread/src/tss_null.cpp38
-rw-r--r--boost/libs/thread/src/win32/thread.cpp1043
-rw-r--r--boost/libs/thread/src/win32/tss_dll.cpp85
-rw-r--r--boost/libs/thread/src/win32/tss_pe.cpp325
10 files changed, 0 insertions, 2909 deletions
diff --git a/boost/libs/thread/build/Jamfile.v2 b/boost/libs/thread/build/Jamfile.v2
deleted file mode 100644
index 62d03427..00000000
--- a/boost/libs/thread/build/Jamfile.v2
+++ /dev/null
@@ -1,322 +0,0 @@
-# $Id$
-# Copyright 2006-2007 Roland Schwarz.
-# Copyright 2007 Anthony Williams
-# Copyright 2011-2012 Vicente J.Botet Escriba.
-# 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)
-
-#########################################################################
-# The boost threading library can be built on top of different API's
-# Currently this is the win32 API and the pthreads API.
-# Pthread is native on unix variants.
-# To get pthread on windows you need the pthread win32 library
-# http://sourceware.org/pthreads-win32 which is available under LGPL.
-#
-# You need to provide the include path and lib path in the variables
-# PTW32_INCLUDE and PTW32_LIB respectively. You can specify these
-# paths in site-config.jam, user-config.jam or in the environment.
-# A new feature is provided to request a specific API:
-# <threadapi>win32 and <threadapi)pthread.
-#
-# The naming of the resulting libraries is mostly the same for the
-# variant native to the build platform, i.e.
-# boost_thread and the boost specific tagging.
-# For the library variant that is not native on the build platform
-# an additional tag is applied:
-# boost_thread_pthread for the pthread variant on windows, and
-# boost_thread_win32 for the win32 variant (likely when built on cygwin).
-#
-# To request the pthread variant on windows, from boost root you would
-# say e.g:
-# bjam msvc-8.0 --with-thread install threadapi=pthread
-#########################################################################
-
-import os ;
-import feature ;
-import indirect ;
-import path ;
-import configure ;
-
-project boost/thread
- : source-location ../src
- : requirements <threading>multi
- #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
- #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
- <link>static:<define>BOOST_THREAD_BUILD_LIB=1
- <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
- -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
- <tag>@$(__name__).tag
- <toolset>gcc:<cxxflags>-Wno-long-long
- #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
- #<define>BOOST_SYSTEM_NO_DEPRECATED
- #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
-
- <library>/boost/system//boost_system
- #-pedantic -ansi -std=gnu++0x -Wextra -fpermissive
- <warnings>all
- <toolset>gcc:<cxxflags>-Wextra
- <toolset>gcc:<cxxflags>-pedantic
- <toolset>gcc:<cxxflags>-Wno-long-long
- #<toolset>gcc:<cxxflags>-ansi
- #<toolset>gcc:<cxxflags>-fpermissive
- <toolset>gcc-4:<cxxflags>-Wno-variadic-macros
- <toolset>gcc-5:<cxxflags>-Wno-variadic-macros
- #<toolset>gcc:<cxxflags>-Wunused-local-typedefs
- <toolset>gcc:<cxxflags>-Wunused-function
- <toolset>gcc:<cxxflags>-Wno-unused-parameter
-
- <toolset>darwin:<cxxflags>-Wextra
- <toolset>darwin:<cxxflags>-pedantic
- #<toolset>darwin:<cxxflags>-ansi
- <toolset>darwin:<cxxflags>-fpermissive
- <toolset>darwin:<cxxflags>-Wno-long-long
- #<toolset>darwin:<cxxflags>-Wno-variadic-macros
- <toolset>darwin-4:<cxxflags>-Wno-variadic-macros
- <toolset>darwin-5:<cxxflags>-Wno-variadic-macros
- #<toolset>darwin:<cxxflags>-Wunused-local-typedefs
- <toolset>darwin:<cxxflags>-Wunused-function
- <toolset>darwin:<cxxflags>-Wno-unused-parameter
-
- #<toolset>pathscale:<cxxflags>-Wextra
- <toolset>pathscale:<cxxflags>-Wno-long-long
- <toolset>pathscale:<cxxflags>-pedantic
-
- <toolset>clang:<warnings>on
- <toolset>clang:<cxxflags>-Wextra
- #<toolset>clang:<cxxflags>-ansi
- #<toolset>clang:<cxxflags>-fpermissive
- <toolset>clang:<cxxflags>-Wno-long-long
- <toolset>clang:<cxxflags>-Wunused-function
- <toolset>clang:<cxxflags>-Wno-variadic-macros
- <toolset>clang:<cxxflags>-Wno-unused-parameter
-
- #<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc-mingw-4.6.0:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc-mingw-4.6.3:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc-mingw-4.7.0:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc-mingw-4.8.0:<cxxflags>-fdiagnostics-show-option
- #<toolset>gcc:<cxxflags>-Wno-missing-field-initializers
-
- <toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor
- <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
-
- #<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
- #<toolset>clang-2.8:<cxxflags>-Wno-unused-function
- #<toolset>clang-2.9:<cxxflags>-Wno-delete-non-virtual-dtor
- #<toolset>clang-2.9:<cxxflags>-Wno-unused-function
- <toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
- #<toolset>clang-3.0:<cxxflags>-Wno-unused-function
- #<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
-
-# Note: Some of the remarks from the Intel compiler are disabled
-# remark #193: zero used for undefined preprocessing identifier "XXX"
-# remark #304: access control not specified ("public" by default)
-# remark #593: variable "XXX" was set but never used
-# remark #1418: external function definition with no prior declaration
-# remark #2415: variable "XXX" of static storage duration was declared but never referenced
-
- <toolset>intel:<cxxflags>-wd193,304,383,444
- <toolset>intel:<cxxflags>-wd593,981
- <toolset>intel:<cxxflags>-wd1418
- <toolset>intel:<cxxflags>-wd2415
-
- <toolset>msvc:<cxxflags>/wd4100
- <toolset>msvc:<cxxflags>/wd4512
- <toolset>msvc:<cxxflags>/wd6246
-
- <target-os>windows:<define>WIN32_LEAN_AND_MEAN
- <target-os>windows:<define>BOOST_USE_WINDOWS_H
-
- # : default-build <threading>multi
- : usage-requirements # pass these requirement to dependents (i.e. users)
- #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
- #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
- <link>static:<define>BOOST_THREAD_BUILD_LIB=1
- <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
- #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
- #<define>BOOST_SYSTEM_NO_DEPRECATED
- #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
- <library>/boost/system//boost_system
- ;
-
-local rule default_threadapi ( )
-{
- local api = pthread ;
- if [ os.name ] = "NT" { api = win32 ; }
- return $(api) ;
-}
-
-feature.feature threadapi : pthread win32 : propagated ;
-feature.set-default threadapi : [ default_threadapi ] ;
-
-exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ;
-
-rule tag ( name : type ? : property-set )
-{
- local result = $(name) ;
-
- if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
- {
- local api = [ $(property-set).get <threadapi> ] ;
-
- # non native api gets additional tag
- if $(api) != [ default_threadapi ] {
- result = $(result)_$(api) ;
- }
- }
-
- # forward to the boost tagging rule
- return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
- $(result) : $(type) : $(property-set) ] ;
-}
-
-rule win32_pthread_paths ( properties * )
-{
- local result ;
- local PTW32_INCLUDE ;
- local PTW32_LIB ;
- PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ;
- PTW32_LIB = [ modules.peek : PTW32_LIB ] ;
- PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ;
- PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ;
- PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ;
- PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ;
-
- if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) )
- {
- if ! $(.notified)
- {
- echo "************************************************************" ;
- echo "Trying to build Boost.Thread with pthread support." ;
- echo "If you need pthread you should specify the paths." ;
- echo "You can specify them in site-config.jam, user-config.jam" ;
- echo "or in the environment." ;
- echo "For example:" ;
- echo "PTW32_INCLUDE=C:\\Program Files\\ptw32\\Pre-built2\\include" ;
- echo "PTW32_LIB=C:\\Program Files\\ptw32\\Pre-built2\\lib" ;
- echo "************************************************************" ;
- .notified = true ;
- }
- }
- else
- {
- local include_path = [ path.make $(PTW32_INCLUDE) ] ;
- local lib_path = [ path.make $(PTW32_LIB) ] ;
- local libname = pthread ;
- if <toolset>msvc in $(properties)
- {
- libname = $(libname)VC2.lib ;
- }
- if <toolset>gcc in $(properties)
- {
- libname = lib$(libname)GC2.a ;
- }
- lib_path = [ path.glob $(lib_path) : $(libname) ] ;
- if ! $(lib_path)
- {
- if ! $(.notified)
- {
- echo "************************************************************" ;
- echo "Trying to build Boost.Thread with pthread support." ;
- echo "But the library" $(libname) "could not be found in path" ;
- echo $(PTW32_LIB) ;
- echo "************************************************************" ;
- .notified = true ;
- }
- }
- else
- {
- result += <include>$(include_path) ;
- result += <library>$(lib_path) ;
- }
- }
- return $(result) ;
-}
-
-rule usage-requirements ( properties * )
-{
- local result ;
- if <threadapi>pthread in $(properties)
- {
- result += <define>BOOST_THREAD_POSIX ;
- if <target-os>windows in $(properties)
- {
- result += [ win32_pthread_paths $(properties) ] ;
- # TODO: What is for static linking? Is the <library> also needed
- # in that case?
- }
- }
-
- #if ! <toolset>vacpp in $(properties) || <toolset-vacpp:version>11.1 in $(properties) || <toolset-vacpp:version>12.1.0.1 in $(properties) || <toolset-vacpp:version>12.1 in $(properties)
- #{
- result += <library>/boost/chrono//boost_chrono ;
- #}
-
- return $(result) ;
-}
-
-rule requirements ( properties * )
-{
- local result ;
-
- if <threadapi>pthread in $(properties)
- {
- result += <define>BOOST_THREAD_POSIX ;
- if <target-os>windows in $(properties)
- {
- local paths = [ win32_pthread_paths $(properties) ] ;
- if $(paths)
- {
- result += $(paths) ;
- }
- else
- {
- result = <build>no ;
- }
- }
- result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
- if ! [ configure.builds has_atomic_flag_lockfree
- : $(properties) : "lockfree boost::atomic_flag" ] {
- result += <library>/boost/atomic//boost_atomic ;
- }
- } else {
- result += <define>BOOST_THREAD_USES_CHRONO ;
- result += <library>/boost/chrono//boost_chrono ;
- }
-
- return $(result) ;
-}
-
-alias thread_sources
- : ## win32 sources ##
- win32/thread.cpp
- win32/tss_dll.cpp
- win32/tss_pe.cpp
- future.cpp
- : ## requirements ##
- <threadapi>win32
- ;
-
-alias thread_sources
- : ## pthread sources ##
- pthread/thread.cpp
- pthread/once.cpp
- future.cpp
- : ## requirements ##
- <threadapi>pthread
- ;
-
-explicit thread_sources ;
-
-lib boost_thread
- : thread_sources
- : <conditional>@requirements
- :
- : <link>shared:<define>BOOST_THREAD_USE_DLL=1
- <link>static:<define>BOOST_THREAD_USE_LIB=1
- <conditional>@usage-requirements
- ;
-
-boost-install boost_thread ; \ No newline at end of file
diff --git a/boost/libs/thread/build/has_atomic_flag_lockfree_test.cpp b/boost/libs/thread/build/has_atomic_flag_lockfree_test.cpp
deleted file mode 100644
index ca694054..00000000
--- a/boost/libs/thread/build/has_atomic_flag_lockfree_test.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2013, Petr Machata, Red Hat Inc.
-//
-// Use modification and distribution are subject to the boost Software
-// License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
-
-#include "../../../boost/atomic.hpp"
-#include "../../../boost/static_assert.hpp"
-
-int main(int argc, char *argv[])
-{
- BOOST_STATIC_ASSERT(BOOST_ATOMIC_FLAG_LOCK_FREE);
- return 0;
-}
diff --git a/boost/libs/thread/src/future.cpp b/boost/libs/thread/src/future.cpp
deleted file mode 100644
index 4aeac94a..00000000
--- a/boost/libs/thread/src/future.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// (C) Copyright 2012 Vicente J. Botet Escriba
-// Use, modification and distribution are subject to 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)
-
-#include <boost/thread/detail/config.hpp>
-#ifndef BOOST_NO_EXCEPTIONS
-
-
-#include <boost/thread/futures/future_error_code.hpp>
-#include <string>
-
-namespace boost
-{
-
- namespace thread_detail
- {
-
- class future_error_category :
- public boost::system::error_category
- {
- public:
- virtual const char* name() const BOOST_NOEXCEPT;
- virtual std::string message(int ev) const;
- };
-
- const char*
- future_error_category::name() const BOOST_NOEXCEPT
- {
- return "future";
- }
-
- std::string
- future_error_category::message(int ev) const
- {
- switch (BOOST_SCOPED_ENUM_NATIVE(future_errc)(ev))
- {
- case future_errc::broken_promise:
- return std::string("The associated promise has been destructed prior "
- "to the associated state becoming ready.");
- case future_errc::future_already_retrieved:
- return std::string("The future has already been retrieved from "
- "the promise or packaged_task.");
- case future_errc::promise_already_satisfied:
- return std::string("The state of the promise has already been set.");
- case future_errc::no_state:
- return std::string("Operation not permitted on an object without "
- "an associated state.");
- }
- return std::string("unspecified future_errc value\n");
- }
- future_error_category future_error_category_var;
- }
-
- BOOST_THREAD_DECL
- const system::error_category&
- future_category() BOOST_NOEXCEPT
- {
- return thread_detail::future_error_category_var;
- }
-
-}
-#endif
-
diff --git a/boost/libs/thread/src/pthread/once.cpp b/boost/libs/thread/src/pthread/once.cpp
deleted file mode 100644
index 2395cff6..00000000
--- a/boost/libs/thread/src/pthread/once.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (C) 2007 Anthony Williams
-//
-// 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)
-
-#include <boost/thread/detail/config.hpp>
-#ifdef BOOST_THREAD_ONCE_ATOMIC
-#include "./once_atomic.cpp"
-#else
-#define __STDC_CONSTANT_MACROS
-#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
-#include <boost/thread/once.hpp>
-#include <boost/assert.hpp>
-#include <boost/throw_exception.hpp>
-#include <pthread.h>
-#include <stdlib.h>
-#include <memory>
-#include <string.h> // memcmp.
-namespace boost
-{
- namespace thread_detail
- {
- BOOST_THREAD_DECL uintmax_atomic_t once_global_epoch=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C;
- BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER;
- BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER;
-
- namespace
- {
- pthread_key_t epoch_tss_key;
- pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT;
-
- extern "C"
- {
- static void delete_epoch_tss_data(void* data)
- {
- free(data);
- }
-
- static void create_epoch_tss_key()
- {
- BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data));
- }
- }
-
-#if defined BOOST_THREAD_PATCH
- const pthread_once_t pthread_once_init_value=PTHREAD_ONCE_INIT;
- struct BOOST_THREAD_DECL delete_epoch_tss_key_on_dlclose_t
- {
- delete_epoch_tss_key_on_dlclose_t()
- {
- }
- ~delete_epoch_tss_key_on_dlclose_t()
- {
- if(memcmp(&epoch_tss_key_flag, &pthread_once_init_value, sizeof(pthread_once_t)))
- {
- void* data = pthread_getspecific(epoch_tss_key);
- if (data)
- delete_epoch_tss_data(data);
- pthread_key_delete(epoch_tss_key);
- }
- }
- };
- delete_epoch_tss_key_on_dlclose_t delete_epoch_tss_key_on_dlclose;
-#endif
- }
-
- uintmax_atomic_t& get_once_per_thread_epoch()
- {
- BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key));
- void* data=pthread_getspecific(epoch_tss_key);
- if(!data)
- {
- data=malloc(sizeof(thread_detail::uintmax_atomic_t));
- if(!data) BOOST_THROW_EXCEPTION(std::bad_alloc());
- BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data));
- *static_cast<thread_detail::uintmax_atomic_t*>(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C;
- }
- return *static_cast<thread_detail::uintmax_atomic_t*>(data);
- }
- }
-
-}
-#endif //
diff --git a/boost/libs/thread/src/pthread/once_atomic.cpp b/boost/libs/thread/src/pthread/once_atomic.cpp
deleted file mode 100644
index b7ee1dc5..00000000
--- a/boost/libs/thread/src/pthread/once_atomic.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-// (C) Copyright 2013 Andrey Semashev
-// (C) Copyright 2013 Vicente J. Botet Escriba
-//
-// 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)
-
-//#define __STDC_CONSTANT_MACROS
-#include <boost/thread/detail/config.hpp>
-#include <boost/thread/once.hpp>
-#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/atomic.hpp>
-#include <boost/memory_order.hpp>
-#include <pthread.h>
-
-namespace boost
-{
- namespace thread_detail
- {
-
- enum flag_states
- {
- uninitialized, in_progress, initialized
- };
-
-
-#ifndef BOOST_THREAD_PROVIDES_ONCE_CXX11
- BOOST_STATIC_ASSERT_MSG(sizeof(atomic_int_type) == sizeof(atomic_type), "Boost.Thread: unsupported platform");
-#endif
-
- static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_cond_t once_cv = PTHREAD_COND_INITIALIZER;
-
- BOOST_THREAD_DECL bool enter_once_region(once_flag& flag) BOOST_NOEXCEPT
- {
- atomic_type& f = get_atomic_storage(flag);
- if (f.load(memory_order_acquire) != initialized)
- {
- pthread::pthread_mutex_scoped_lock lk(&once_mutex);
- if (f.load(memory_order_acquire) != initialized)
- {
- while (true)
- {
- atomic_int_type expected = uninitialized;
- if (f.compare_exchange_strong(expected, in_progress, memory_order_acq_rel, memory_order_acquire))
- {
- // We have set the flag to in_progress
- return true;
- }
- else if (expected == initialized)
- {
- // Another thread managed to complete the initialization
- return false;
- }
- else
- {
- // Wait until the initialization is complete
- //pthread::pthread_mutex_scoped_lock lk(&once_mutex);
- BOOST_VERIFY(!pthread_cond_wait(&once_cv, &once_mutex));
- }
- }
- }
- }
- return false;
- }
-
- BOOST_THREAD_DECL void commit_once_region(once_flag& flag) BOOST_NOEXCEPT
- {
- atomic_type& f = get_atomic_storage(flag);
- {
- pthread::pthread_mutex_scoped_lock lk(&once_mutex);
- f.store(initialized, memory_order_release);
- }
- BOOST_VERIFY(!pthread_cond_broadcast(&once_cv));
- }
-
- BOOST_THREAD_DECL void rollback_once_region(once_flag& flag) BOOST_NOEXCEPT
- {
- atomic_type& f = get_atomic_storage(flag);
- {
- pthread::pthread_mutex_scoped_lock lk(&once_mutex);
- f.store(uninitialized, memory_order_release);
- }
- BOOST_VERIFY(!pthread_cond_broadcast(&once_cv));
- }
-
- } // namespace thread_detail
-
-} // namespace boost
diff --git a/boost/libs/thread/src/pthread/thread.cpp b/boost/libs/thread/src/pthread/thread.cpp
deleted file mode 100644
index 12c3cf96..00000000
--- a/boost/libs/thread/src/pthread/thread.cpp
+++ /dev/null
@@ -1,846 +0,0 @@
-// Copyright (C) 2001-2003
-// William E. Kempf
-// Copyright (C) 2007-8 Anthony Williams
-// (C) Copyright 2011-2012 Vicente J. Botet Escriba
-//
-// 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)
-
-#include <boost/thread/detail/config.hpp>
-
-#include <boost/thread/thread_only.hpp>
-#if defined BOOST_THREAD_USES_DATETIME
-#include <boost/thread/xtime.hpp>
-#endif
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/once.hpp>
-#include <boost/thread/tss.hpp>
-#include <boost/thread/future.hpp>
-
-#ifdef __GLIBC__
-#include <sys/sysinfo.h>
-#elif defined(__APPLE__) || defined(__FreeBSD__)
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#elif defined BOOST_HAS_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/trim.hpp>
-#include <boost/lexical_cast.hpp>
-
-#include <fstream>
-#include <string>
-#include <set>
-#include <vector>
-#include <string.h> // memcmp.
-
-namespace boost
-{
- namespace detail
- {
- thread_data_base::~thread_data_base()
- {
- for (notify_list_t::iterator i = notify.begin(), e = notify.end();
- i != e; ++i)
- {
- i->second->unlock();
- i->first->notify_all();
- }
- for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end();
- i != e; ++i)
- {
- (*i)->make_ready();
- }
- }
-
- struct thread_exit_callback_node
- {
- boost::detail::thread_exit_function_base* func;
- thread_exit_callback_node* next;
-
- thread_exit_callback_node(boost::detail::thread_exit_function_base* func_,
- thread_exit_callback_node* next_):
- func(func_),next(next_)
- {}
- };
-
- namespace
- {
-#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
- boost::once_flag current_thread_tls_init_flag;
-#else
- boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
-#endif
- pthread_key_t current_thread_tls_key;
-
- extern "C"
- {
- static void tls_destructor(void* data)
- {
- //boost::detail::thread_data_base* thread_info=static_cast<boost::detail::thread_data_base*>(data);
- boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(data)->shared_from_this();
-
- if(thread_info)
- {
- while(!thread_info->tss_data.empty() || thread_info->thread_exit_callbacks)
- {
-
- while(thread_info->thread_exit_callbacks)
- {
- detail::thread_exit_callback_node* const current_node=thread_info->thread_exit_callbacks;
- thread_info->thread_exit_callbacks=current_node->next;
- if(current_node->func)
- {
- (*current_node->func)();
- delete current_node->func;
- }
- delete current_node;
- }
- while (!thread_info->tss_data.empty())
- {
- std::map<void const*,detail::tss_data_node>::iterator current
- = thread_info->tss_data.begin();
- if(current->second.func && (current->second.value!=0))
- {
- (*current->second.func)(current->second.value);
- }
- thread_info->tss_data.erase(current);
- }
- }
- thread_info->self.reset();
- }
- }
- }
-
-#if defined BOOST_THREAD_PATCH
- struct delete_current_thread_tls_key_on_dlclose_t
- {
- delete_current_thread_tls_key_on_dlclose_t()
- {
- }
- ~delete_current_thread_tls_key_on_dlclose_t()
- {
- const boost::once_flag uninitialized = BOOST_ONCE_INIT;
- if (memcmp(&current_thread_tls_init_flag, &uninitialized, sizeof(boost::once_flag)))
- {
- void* data = pthread_getspecific(current_thread_tls_key);
- if (data)
- tls_destructor(data);
- pthread_key_delete(current_thread_tls_key);
- }
- }
- };
- delete_current_thread_tls_key_on_dlclose_t delete_current_thread_tls_key_on_dlclose;
-#endif
- void create_current_thread_tls_key()
- {
- BOOST_VERIFY(!pthread_key_create(&current_thread_tls_key,&tls_destructor));
- }
- }
-
- boost::detail::thread_data_base* get_current_thread_data()
- {
- boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- return (boost::detail::thread_data_base*)pthread_getspecific(current_thread_tls_key);
- }
-
- void set_current_thread_data(detail::thread_data_base* new_data)
- {
- boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data));
- }
- }
-
- namespace
- {
- extern "C"
- {
- static void* thread_proxy(void* param)
- {
- //boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
- boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->shared_from_this();
- thread_info->self.reset();
- detail::set_current_thread_data(thread_info.get());
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- BOOST_TRY
- {
-#endif
- thread_info->run();
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
-
- }
- BOOST_CATCH (thread_interrupted const&)
- {
- }
-// Removed as it stops the debugger identifying the cause of the exception
-// Unhandled exceptions still cause the application to terminate
-// BOOST_CATCH(...)
-// {
-// throw;
-//
-// std::terminate();
-// }
- BOOST_CATCH_END
-#endif
- detail::tls_destructor(thread_info.get());
- detail::set_current_thread_data(0);
- boost::lock_guard<boost::mutex> lock(thread_info->data_mutex);
- thread_info->done=true;
- thread_info->done_condition.notify_all();
-
- return 0;
- }
- }
- }
- namespace detail
- {
- struct externally_launched_thread:
- detail::thread_data_base
- {
- externally_launched_thread()
- {
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- interrupt_enabled=false;
-#endif
- }
- ~externally_launched_thread() {
- BOOST_ASSERT(notify.empty());
- notify.clear();
- BOOST_ASSERT(async_states_.empty());
- async_states_.clear();
- }
- void run()
- {}
- void notify_all_at_thread_exit(condition_variable*, mutex*)
- {}
-
- private:
- externally_launched_thread(externally_launched_thread&);
- void operator=(externally_launched_thread&);
- };
-
- thread_data_base* make_external_thread_data()
- {
- thread_data_base* const me(detail::heap_new<externally_launched_thread>());
- me->self.reset(me);
- set_current_thread_data(me);
- return me;
- }
-
-
- thread_data_base* get_or_make_current_thread_data()
- {
- thread_data_base* current_thread_data(get_current_thread_data());
- if(!current_thread_data)
- {
- current_thread_data=make_external_thread_data();
- }
- return current_thread_data;
- }
-
- }
-
-
- thread::thread() BOOST_NOEXCEPT
- {}
-
- bool thread::start_thread_noexcept()
- {
- thread_info->self=thread_info;
- int const res = pthread_create(&thread_info->thread_handle, 0, &thread_proxy, thread_info.get());
- if (res != 0)
- {
- thread_info->self.reset();
- return false;
- }
- return true;
- }
-
- bool thread::start_thread_noexcept(const attributes& attr)
- {
- thread_info->self=thread_info;
- const attributes::native_handle_type* h = attr.native_handle();
- int res = pthread_create(&thread_info->thread_handle, h, &thread_proxy, thread_info.get());
- if (res != 0)
- {
- thread_info->self.reset();
- return false;
- }
- int detached_state;
- res = pthread_attr_getdetachstate(h, &detached_state);
- if (res != 0)
- {
- thread_info->self.reset();
- return false;
- }
- if (PTHREAD_CREATE_DETACHED==detached_state)
- {
- detail::thread_data_ptr local_thread_info;
- thread_info.swap(local_thread_info);
-
- if(local_thread_info)
- {
- //lock_guard<mutex> lock(local_thread_info->data_mutex);
- if(!local_thread_info->join_started)
- {
- //BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle));
- local_thread_info->join_started=true;
- local_thread_info->joined=true;
- }
- }
- }
- return true;
- }
-
-
-
- detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const
- {
- return thread_info;
- }
-
- bool thread::join_noexcept()
- {
- detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- bool do_join=false;
-
- {
- unique_lock<mutex> lock(local_thread_info->data_mutex);
- while(!local_thread_info->done)
- {
- local_thread_info->done_condition.wait(lock);
- }
- do_join=!local_thread_info->join_started;
-
- if(do_join)
- {
- local_thread_info->join_started=true;
- }
- else
- {
- while(!local_thread_info->joined)
- {
- local_thread_info->done_condition.wait(lock);
- }
- }
- }
- if(do_join)
- {
- void* result=0;
- BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
- lock_guard<mutex> lock(local_thread_info->data_mutex);
- local_thread_info->joined=true;
- local_thread_info->done_condition.notify_all();
- }
-
- if(thread_info==local_thread_info)
- {
- thread_info.reset();
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
- bool thread::do_try_join_until_noexcept(struct timespec const &timeout, bool& res)
- {
- detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- bool do_join=false;
-
- {
- unique_lock<mutex> lock(local_thread_info->data_mutex);
- while(!local_thread_info->done)
- {
- if(!local_thread_info->done_condition.do_wait_until(lock,timeout))
- {
- res=false;
- return true;
- }
- }
- do_join=!local_thread_info->join_started;
-
- if(do_join)
- {
- local_thread_info->join_started=true;
- }
- else
- {
- while(!local_thread_info->joined)
- {
- local_thread_info->done_condition.wait(lock);
- }
- }
- }
- if(do_join)
- {
- void* result=0;
- BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
- lock_guard<mutex> lock(local_thread_info->data_mutex);
- local_thread_info->joined=true;
- local_thread_info->done_condition.notify_all();
- }
-
- if(thread_info==local_thread_info)
- {
- thread_info.reset();
- }
- res=true;
- return true;
- }
- else
- {
- return false;
- }
- }
-
- bool thread::joinable() const BOOST_NOEXCEPT
- {
- return (get_thread_info)()?true:false;
- }
-
-
- void thread::detach()
- {
- detail::thread_data_ptr local_thread_info;
- thread_info.swap(local_thread_info);
-
- if(local_thread_info)
- {
- lock_guard<mutex> lock(local_thread_info->data_mutex);
- if(!local_thread_info->join_started)
- {
- BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle));
- local_thread_info->join_started=true;
- local_thread_info->joined=true;
- }
- }
- }
-
- namespace this_thread
- {
- namespace no_interruption_point
- {
- namespace hidden
- {
- void BOOST_THREAD_DECL sleep_for(const timespec& ts)
- {
-
- if (boost::detail::timespec_ge(ts, boost::detail::timespec_zero()))
- {
-
- # if defined(BOOST_HAS_PTHREAD_DELAY_NP)
- # if defined(__IBMCPP__) || defined(_AIX)
- BOOST_VERIFY(!pthread_delay_np(const_cast<timespec*>(&ts)));
- # else
- BOOST_VERIFY(!pthread_delay_np(&ts));
- # endif
- # elif defined(BOOST_HAS_NANOSLEEP)
- // nanosleep takes a timespec that is an offset, not
- // an absolute time.
- nanosleep(&ts, 0);
- # else
- mutex mx;
- unique_lock<mutex> lock(mx);
- condition_variable cond;
- cond.do_wait_for(lock, ts);
- # endif
- }
- }
-
- void BOOST_THREAD_DECL sleep_until(const timespec& ts)
- {
- timespec now = boost::detail::timespec_now();
- if (boost::detail::timespec_gt(ts, now))
- {
- for (int foo=0; foo < 5; ++foo)
- {
-
- # if defined(BOOST_HAS_PTHREAD_DELAY_NP)
- timespec d = boost::detail::timespec_minus(ts, now);
- BOOST_VERIFY(!pthread_delay_np(&d));
- # elif defined(BOOST_HAS_NANOSLEEP)
- // nanosleep takes a timespec that is an offset, not
- // an absolute time.
- timespec d = boost::detail::timespec_minus(ts, now);
- nanosleep(&d, 0);
- # else
- mutex mx;
- unique_lock<mutex> lock(mx);
- condition_variable cond;
- cond.do_wait_until(lock, ts);
- # endif
- timespec now2 = boost::detail::timespec_now();
- if (boost::detail::timespec_ge(now2, ts))
- {
- return;
- }
- }
- }
- }
-
- }
- }
- namespace hidden
- {
- void BOOST_THREAD_DECL sleep_for(const timespec& ts)
- {
- boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data();
-
- if(thread_info)
- {
- unique_lock<mutex> lk(thread_info->sleep_mutex);
- while( thread_info->sleep_condition.do_wait_for(lk,ts)) {}
- }
- else
- {
- boost::this_thread::no_interruption_point::hidden::sleep_for(ts);
- }
- }
-
- void BOOST_THREAD_DECL sleep_until(const timespec& ts)
- {
- boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data();
-
- if(thread_info)
- {
- unique_lock<mutex> lk(thread_info->sleep_mutex);
- while(thread_info->sleep_condition.do_wait_until(lk,ts)) {}
- }
- else
- {
- boost::this_thread::no_interruption_point::hidden::sleep_until(ts);
- }
- }
- } // hidden
- } // this_thread
-
- namespace this_thread
- {
- void yield() BOOST_NOEXCEPT
- {
-# if defined(BOOST_HAS_SCHED_YIELD)
- BOOST_VERIFY(!sched_yield());
-# elif defined(BOOST_HAS_PTHREAD_YIELD)
- BOOST_VERIFY(!pthread_yield());
-//# elif defined BOOST_THREAD_USES_DATETIME
-// xtime xt;
-// xtime_get(&xt, TIME_UTC_);
-// sleep(xt);
-// sleep_for(chrono::milliseconds(0));
-# else
-#error
- timespec ts;
- ts.tv_sec= 0;
- ts.tv_nsec= 0;
- hidden::sleep_for(ts);
-# endif
- }
- }
- unsigned thread::hardware_concurrency() BOOST_NOEXCEPT
- {
-#if defined(PTW32_VERSION) || defined(__hpux)
- return pthread_num_processors_np();
-#elif defined(__APPLE__) || defined(__FreeBSD__)
- int count;
- size_t size=sizeof(count);
- return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
-#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
- int const count=sysconf(_SC_NPROCESSORS_ONLN);
- return (count>0)?count:0;
-#elif defined(__GLIBC__)
- return get_nprocs();
-#else
- return 0;
-#endif
- }
-
- unsigned thread::physical_concurrency() BOOST_NOEXCEPT
- {
-#ifdef __linux__
- try {
- using namespace std;
-
- ifstream proc_cpuinfo ("/proc/cpuinfo");
-
- const string physical_id("physical id"), core_id("core id");
-
- typedef std::pair<unsigned, unsigned> core_entry; // [physical ID, core id]
-
- std::set<core_entry> cores;
-
- core_entry current_core_entry;
-
- string line;
- while ( getline(proc_cpuinfo, line) ) {
- if (line.empty())
- continue;
-
- vector<string> key_val(2);
- boost::split(key_val, line, boost::is_any_of(":"));
-
- if (key_val.size() != 2)
- return hardware_concurrency();
-
- string key = key_val[0];
- string value = key_val[1];
- boost::trim(key);
- boost::trim(value);
-
- if (key == physical_id) {
- current_core_entry.first = boost::lexical_cast<unsigned>(value);
- continue;
- }
-
- if (key == core_id) {
- current_core_entry.second = boost::lexical_cast<unsigned>(value);
- cores.insert(current_core_entry);
- continue;
- }
- }
- // Fall back to hardware_concurrency() in case
- // /proc/cpuinfo is formatted differently than we expect.
- return cores.size() != 0 ? cores.size() : hardware_concurrency();
- } catch(...) {
- return hardware_concurrency();
- }
-#elif defined(__APPLE__)
- int count;
- size_t size=sizeof(count);
- return sysctlbyname("hw.physicalcpu",&count,&size,NULL,0)?0:count;
-#else
- return hardware_concurrency();
-#endif
- }
-
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- void thread::interrupt()
- {
- detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- lock_guard<mutex> lk(local_thread_info->data_mutex);
- local_thread_info->interrupt_requested=true;
- if(local_thread_info->current_cond)
- {
- boost::pthread::pthread_mutex_scoped_lock internal_lock(local_thread_info->cond_mutex);
- BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond));
- }
- }
- }
-
- bool thread::interruption_requested() const BOOST_NOEXCEPT
- {
- detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- lock_guard<mutex> lk(local_thread_info->data_mutex);
- return local_thread_info->interrupt_requested;
- }
- else
- {
- return false;
- }
- }
-#endif
-
- thread::native_handle_type thread::native_handle()
- {
- detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- lock_guard<mutex> lk(local_thread_info->data_mutex);
- return local_thread_info->thread_handle;
- }
- else
- {
- return pthread_t();
- }
- }
-
-
-
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- namespace this_thread
- {
- void interruption_point()
- {
-#ifndef BOOST_NO_EXCEPTIONS
- boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
- if(thread_info && thread_info->interrupt_enabled)
- {
- lock_guard<mutex> lg(thread_info->data_mutex);
- if(thread_info->interrupt_requested)
- {
- thread_info->interrupt_requested=false;
- throw thread_interrupted();
- }
- }
-#endif
- }
-
- bool interruption_enabled() BOOST_NOEXCEPT
- {
- boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
- return thread_info && thread_info->interrupt_enabled;
- }
-
- bool interruption_requested() BOOST_NOEXCEPT
- {
- boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
- if(!thread_info)
- {
- return false;
- }
- else
- {
- lock_guard<mutex> lg(thread_info->data_mutex);
- return thread_info->interrupt_requested;
- }
- }
-
- disable_interruption::disable_interruption() BOOST_NOEXCEPT:
- interruption_was_enabled(interruption_enabled())
- {
- if(interruption_was_enabled)
- {
- detail::get_current_thread_data()->interrupt_enabled=false;
- }
- }
-
- disable_interruption::~disable_interruption() BOOST_NOEXCEPT
- {
- if(detail::get_current_thread_data())
- {
- detail::get_current_thread_data()->interrupt_enabled=interruption_was_enabled;
- }
- }
-
- restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
- {
- if(d.interruption_was_enabled)
- {
- detail::get_current_thread_data()->interrupt_enabled=true;
- }
- }
-
- restore_interruption::~restore_interruption() BOOST_NOEXCEPT
- {
- if(detail::get_current_thread_data())
- {
- detail::get_current_thread_data()->interrupt_enabled=false;
- }
- }
- }
-#endif
-
- namespace detail
- {
- void add_thread_exit_function(thread_exit_function_base* func)
- {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- thread_exit_callback_node* const new_node=
- heap_new<thread_exit_callback_node>(func,current_thread_data->thread_exit_callbacks);
- current_thread_data->thread_exit_callbacks=new_node;
- }
-
- tss_data_node* find_tss_data(void const* key)
- {
- detail::thread_data_base* const current_thread_data(get_current_thread_data());
- if(current_thread_data)
- {
- std::map<void const*,tss_data_node>::iterator current_node=
- current_thread_data->tss_data.find(key);
- if(current_node!=current_thread_data->tss_data.end())
- {
- return &current_node->second;
- }
- }
- return 0;
- }
-
- void* get_tss_data(void const* key)
- {
- if(tss_data_node* const current_node=find_tss_data(key))
- {
- return current_node->value;
- }
- return 0;
- }
-
- void add_new_tss_node(void const* key,
- boost::shared_ptr<tss_cleanup_function> func,
- void* tss_data)
- {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data)));
- }
-
- void erase_tss_node(void const* key)
- {
- detail::thread_data_base* const current_thread_data(get_current_thread_data());
- if(current_thread_data)
- {
- current_thread_data->tss_data.erase(key);
- }
- }
-
- void set_tss_data(void const* key,
- boost::shared_ptr<tss_cleanup_function> func,
- void* tss_data,bool cleanup_existing)
- {
- if(tss_data_node* const current_node=find_tss_data(key))
- {
- if(cleanup_existing && current_node->func && (current_node->value!=0))
- {
- (*current_node->func)(current_node->value);
- }
- if(func || (tss_data!=0))
- {
- current_node->func=func;
- current_node->value=tss_data;
- }
- else
- {
- erase_tss_node(key);
- }
- }
- else if(func || (tss_data!=0))
- {
- add_new_tss_node(key,func,tss_data);
- }
- }
- }
-
- BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
- {
- detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
- if(current_thread_data)
- {
- current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
- }
- }
-namespace detail {
-
- void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
- {
- detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
- if(current_thread_data)
- {
- current_thread_data->make_ready_at_thread_exit(as);
- }
- }
-}
-
-
-
-}
diff --git a/boost/libs/thread/src/tss_null.cpp b/boost/libs/thread/src/tss_null.cpp
deleted file mode 100644
index b5029f19..00000000
--- a/boost/libs/thread/src/tss_null.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// (C) Copyright Michael Glassford 2004.
-// (C) Copyright 2007 Anthony Williams
-// Use, modification and distribution are subject to 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)
-
-#include <boost/thread/detail/config.hpp>
-
-#if defined(BOOST_HAS_WINTHREADS) && (defined(BOOST_THREAD_BUILD_LIB) || defined(BOOST_THREAD_TEST) || defined(UNDER_CE)) && (!defined(_MSC_VER) || defined(UNDER_CE))
-
-namespace boost
-{
- /*
- This file is a "null" implementation of tss cleanup; it's
- purpose is to to eliminate link errors in cases
- where it is known that tss cleanup is not needed.
- */
-
- void tss_cleanup_implemented(void)
- {
- /*
- This function's sole purpose is to cause a link error in cases where
- automatic tss cleanup is not implemented by Boost.Threads as a
- reminder that user code is responsible for calling the necessary
- functions at the appropriate times (and for implementing an a
- tss_cleanup_implemented() function to eliminate the linker's
- missing symbol error).
-
- If Boost.Threads later implements automatic tss cleanup in cases
- where it currently doesn't (which is the plan), the duplicate
- symbol error will warn the user that their custom solution is no
- longer needed and can be removed.
- */
- }
-
-}
-
-#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) && !defined(_MSC_VER)
diff --git a/boost/libs/thread/src/win32/thread.cpp b/boost/libs/thread/src/win32/thread.cpp
deleted file mode 100644
index 7e2c21bc..00000000
--- a/boost/libs/thread/src/win32/thread.cpp
+++ /dev/null
@@ -1,1043 +0,0 @@
-// 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)
-// (C) Copyright 2007 Anthony Williams
-// (C) Copyright 2007 David Deakins
-// (C) Copyright 2011-2013 Vicente J. Botet Escriba
-
-//#define BOOST_THREAD_VERSION 3
-
-#include <boost/detail/winapi/config.hpp>
-#include <boost/thread/thread_only.hpp>
-#include <boost/thread/once.hpp>
-#include <boost/thread/tss.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/detail/tss_hooks.hpp>
-#include <boost/thread/future.hpp>
-#include <boost/assert.hpp>
-#include <boost/cstdint.hpp>
-#if defined BOOST_THREAD_USES_DATETIME
-#include <boost/date_time/posix_time/conversion.hpp>
-#include <boost/thread/thread_time.hpp>
-#endif
-#include <boost/thread/csbl/memory/unique_ptr.hpp>
-#include <memory>
-#include <algorithm>
-#ifndef UNDER_CE
-#include <process.h>
-#endif
-#include <stdio.h>
-#include <windows.h>
-#include <boost/predef/platform.h>
-
-#if BOOST_PLAT_WINDOWS_RUNTIME
-#include <mutex>
-#include <atomic>
-#include <Activation.h>
-#include <wrl\client.h>
-#include <wrl\event.h>
-#include <wrl\wrappers\corewrappers.h>
-#include <wrl\ftm.h>
-#include <windows.system.threading.h>
-#pragma comment(lib, "runtimeobject.lib")
-#endif
-
-namespace boost
-{
- namespace detail
- {
- thread_data_base::~thread_data_base()
- {
- for (notify_list_t::iterator i = notify.begin(), e = notify.end();
- i != e; ++i)
- {
- i->second->unlock();
- i->first->notify_all();
- }
- for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end();
- i != e; ++i)
- {
- (*i)->make_ready();
- }
- }
- }
-
- namespace
- {
-#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
- boost::once_flag current_thread_tls_init_flag;
-#else
- boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
-#endif
-#if defined(UNDER_CE)
- // Windows CE does not define the TLS_OUT_OF_INDEXES constant.
-#define TLS_OUT_OF_INDEXES 0xFFFFFFFF
-#endif
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- DWORD current_thread_tls_key=TLS_OUT_OF_INDEXES;
-#else
- __declspec(thread) boost::detail::thread_data_base* current_thread_data_base;
-#endif
-
- void create_current_thread_tls_key()
- {
- tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- current_thread_tls_key=TlsAlloc();
- BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES);
-#endif
- }
-
- void cleanup_tls_key()
- {
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- if(current_thread_tls_key!=TLS_OUT_OF_INDEXES)
- {
- TlsFree(current_thread_tls_key);
- current_thread_tls_key=TLS_OUT_OF_INDEXES;
- }
-#endif
- }
-
- void set_current_thread_data(detail::thread_data_base* new_data)
- {
- boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
-#if BOOST_PLAT_WINDOWS_RUNTIME
- current_thread_data_base = new_data;
-#else
- if (current_thread_tls_key != TLS_OUT_OF_INDEXES)
- {
- BOOST_VERIFY(TlsSetValue(current_thread_tls_key, new_data));
- }
- else
- {
- BOOST_VERIFY(false);
- //boost::throw_exception(thread_resource_error());
- }
-#endif
- }
- }
-
- namespace detail
- {
- thread_data_base* get_current_thread_data()
- {
-#if BOOST_PLAT_WINDOWS_RUNTIME
- return current_thread_data_base;
-#else
- if (current_thread_tls_key == TLS_OUT_OF_INDEXES)
- {
- return 0;
- }
- return (detail::thread_data_base*)TlsGetValue(current_thread_tls_key);
-#endif
- }
- }
-
- namespace
- {
-#ifndef BOOST_HAS_THREADEX
-// Windows CE doesn't define _beginthreadex
-
- struct ThreadProxyData
- {
- typedef unsigned (__stdcall* func)(void*);
- func start_address_;
- void* arglist_;
- ThreadProxyData(func start_address,void* arglist) : start_address_(start_address), arglist_(arglist) {}
- };
-
- DWORD WINAPI ThreadProxy(LPVOID args)
- {
- boost::csbl::unique_ptr<ThreadProxyData> data(reinterpret_cast<ThreadProxyData*>(args));
- DWORD ret=data->start_address_(data->arglist_);
- return ret;
- }
-
- //typedef void* uintptr_t;
-
- inline uintptr_t _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*),
- void* arglist, unsigned initflag, unsigned* thrdaddr)
- {
- DWORD threadID;
- ThreadProxyData* data = new ThreadProxyData(start_address,arglist);
- HANDLE hthread=CreateThread(static_cast<LPSECURITY_ATTRIBUTES>(security),stack_size,ThreadProxy,
- data,initflag,&threadID);
- if (hthread==0) {
- delete data;
- return 0;
- }
- *thrdaddr=threadID;
- return reinterpret_cast<uintptr_t const>(hthread);
- }
-
-#endif
-
- }
-
- namespace detail
- {
- struct thread_exit_callback_node
- {
- boost::detail::thread_exit_function_base* func;
- thread_exit_callback_node* next;
-
- thread_exit_callback_node(boost::detail::thread_exit_function_base* func_,
- thread_exit_callback_node* next_):
- func(func_),next(next_)
- {}
- };
-
- }
-
-#if BOOST_PLAT_WINDOWS_RUNTIME
- namespace detail
- {
- std::atomic_uint threadCount;
-
- bool win32::scoped_winrt_thread::start(thread_func address, void *parameter, unsigned int *thrdId)
- {
- Microsoft::WRL::ComPtr<ABI::Windows::System::Threading::IThreadPoolStatics> threadPoolFactory;
- HRESULT hr = ::Windows::Foundation::GetActivationFactory(
- Microsoft::WRL::Wrappers::HStringReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(),
- &threadPoolFactory);
- if (hr != S_OK)
- {
- return false;
- }
-
- // Create event for tracking work item completion.
- *thrdId = ++threadCount;
- handle completionHandle = CreateEventExW(NULL, NULL, 0, EVENT_ALL_ACCESS);
- if (!completionHandle)
- {
- return false;
- }
- m_completionHandle = completionHandle;
-
- // Create new work item.
- Microsoft::WRL::ComPtr<ABI::Windows::System::Threading::IWorkItemHandler> workItem =
- Microsoft::WRL::Callback<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, ABI::Windows::System::Threading::IWorkItemHandler, Microsoft::WRL::FtmBase>>
- ([address, parameter, completionHandle](ABI::Windows::Foundation::IAsyncAction *)
- {
- // Add a reference since we need to access the completionHandle after the thread_start_function.
- // This is to handle cases where detach() was called and run_thread_exit_callbacks() would end
- // up closing the handle.
- ::boost::detail::thread_data_base* const thread_info(reinterpret_cast<::boost::detail::thread_data_base*>(parameter));
- intrusive_ptr_add_ref(thread_info);
-
- __try
- {
- address(parameter);
- }
- __finally
- {
- SetEvent(completionHandle);
- intrusive_ptr_release(thread_info);
- }
- return S_OK;
- });
-
- // Schedule work item on the threadpool.
- Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncAction> asyncAction;
- hr = threadPoolFactory->RunWithPriorityAndOptionsAsync(
- workItem.Get(),
- ABI::Windows::System::Threading::WorkItemPriority_Normal,
- ABI::Windows::System::Threading::WorkItemOptions_TimeSliced,
- &asyncAction);
- return hr == S_OK;
- }
- }
-#endif
-
- namespace
- {
- void run_thread_exit_callbacks()
- {
- detail::thread_data_ptr current_thread_data(detail::get_current_thread_data(),false);
- if(current_thread_data)
- {
- while(! current_thread_data->tss_data.empty() || current_thread_data->thread_exit_callbacks)
- {
- while(current_thread_data->thread_exit_callbacks)
- {
- detail::thread_exit_callback_node* const current_node=current_thread_data->thread_exit_callbacks;
- current_thread_data->thread_exit_callbacks=current_node->next;
- if(current_node->func)
- {
- (*current_node->func)();
- boost::detail::heap_delete(current_node->func);
- }
- boost::detail::heap_delete(current_node);
- }
- while (!current_thread_data->tss_data.empty())
- {
- std::map<void const*,detail::tss_data_node>::iterator current
- = current_thread_data->tss_data.begin();
- if(current->second.func && (current->second.value!=0))
- {
- (*current->second.func)(current->second.value);
- }
- current_thread_data->tss_data.erase(current);
- }
- }
- set_current_thread_data(0);
- }
- }
-
- unsigned __stdcall thread_start_function(void* param)
- {
- detail::thread_data_base* const thread_info(reinterpret_cast<detail::thread_data_base*>(param));
- set_current_thread_data(thread_info);
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- BOOST_TRY
- {
-#endif
- thread_info->run();
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- }
- BOOST_CATCH(thread_interrupted const&)
- {
- }
-// Removed as it stops the debugger identifying the cause of the exception
-// Unhandled exceptions still cause the application to terminate
-// BOOST_CATCH(...)
-// {
-// std::terminate();
-// }
- BOOST_CATCH_END
-#endif
- run_thread_exit_callbacks();
- return 0;
- }
- }
-
- thread::thread() BOOST_NOEXCEPT
- {}
-
- bool thread::start_thread_noexcept()
- {
-#if BOOST_PLAT_WINDOWS_RUNTIME
- intrusive_ptr_add_ref(thread_info.get());
- if (!thread_info->thread_handle.start(&thread_start_function, thread_info.get(), &thread_info->id))
- {
- intrusive_ptr_release(thread_info.get());
-// boost::throw_exception(thread_resource_error());
- return false;
- }
- return true;
-#else
- uintptr_t const new_thread=_beginthreadex(0,0,&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
- if(!new_thread)
- {
- return false;
-// boost::throw_exception(thread_resource_error());
- }
- intrusive_ptr_add_ref(thread_info.get());
- thread_info->thread_handle=(detail::win32::handle)(new_thread);
- ResumeThread(thread_info->thread_handle);
- return true;
-#endif
- }
-
- bool thread::start_thread_noexcept(const attributes& attr)
- {
-#if BOOST_PLAT_WINDOWS_RUNTIME
- // Stack size isn't supported with Windows Runtime.
- attr;
- return start_thread_noexcept();
-#else
- //uintptr_t const new_thread=_beginthreadex(attr.get_security(),attr.get_stack_size(),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
- uintptr_t const new_thread=_beginthreadex(0,static_cast<unsigned int>(attr.get_stack_size()),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
- if(!new_thread)
- {
- return false;
-// boost::throw_exception(thread_resource_error());
- }
- intrusive_ptr_add_ref(thread_info.get());
- thread_info->thread_handle=(detail::win32::handle)(new_thread);
- ResumeThread(thread_info->thread_handle);
- return true;
-#endif
- }
-
- thread::thread(detail::thread_data_ptr data):
- thread_info(data)
- {}
-
- namespace
- {
- struct externally_launched_thread:
- detail::thread_data_base
- {
- externally_launched_thread()
- {
- ++count;
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- interruption_enabled=false;
-#endif
- }
- ~externally_launched_thread() {
- BOOST_ASSERT(notify.empty());
- notify.clear();
- BOOST_ASSERT(async_states_.empty());
- async_states_.clear();
- }
-
- void run()
- {}
- void notify_all_at_thread_exit(condition_variable*, mutex*)
- {}
-
- private:
- externally_launched_thread(externally_launched_thread&);
- void operator=(externally_launched_thread&);
- };
-
- void make_external_thread_data()
- {
- externally_launched_thread* me=detail::heap_new<externally_launched_thread>();
- BOOST_TRY
- {
- set_current_thread_data(me);
- }
- BOOST_CATCH(...)
- {
- detail::heap_delete(me);
- BOOST_RETHROW
- }
- BOOST_CATCH_END
- }
-
- detail::thread_data_base* get_or_make_current_thread_data()
- {
- detail::thread_data_base* current_thread_data(detail::get_current_thread_data());
- if(!current_thread_data)
- {
- make_external_thread_data();
- current_thread_data=detail::get_current_thread_data();
- }
- return current_thread_data;
- }
- }
-
- thread::id thread::get_id() const BOOST_NOEXCEPT
- {
-#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(!local_thread_info)
- {
- return 0;
- }
- return local_thread_info->id;
-#else
- return thread::id((get_thread_info)());
-#endif
- }
-
- bool thread::joinable() const BOOST_NOEXCEPT
- {
- detail::thread_data_ptr local_thread_info = (get_thread_info)();
- if(!local_thread_info)
- {
- return false;
- }
- return true;
- }
- bool thread::join_noexcept()
- {
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- this_thread::interruptible_wait(this->native_handle(),detail::timeout::sentinel());
- release_handle();
- return true;
- }
- else
- {
- return false;
- }
- }
-
-#if defined BOOST_THREAD_USES_DATETIME
- bool thread::timed_join(boost::system_time const& wait_until)
- {
- return do_try_join_until(boost::detail::get_milliseconds_until(wait_until));
- }
-#endif
- bool thread::do_try_join_until_noexcept(uintmax_t milli, bool& res)
- {
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- if(!this_thread::interruptible_wait(this->native_handle(),milli))
- {
- res=false;
- return true;
- }
- release_handle();
- res=true;
- return true;
- }
- else
- {
- return false;
- }
- }
-
- void thread::detach()
- {
- release_handle();
- }
-
- void thread::release_handle()
- {
- thread_info=0;
- }
-
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- void thread::interrupt()
- {
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- local_thread_info->interrupt();
- }
- }
-
- bool thread::interruption_requested() const BOOST_NOEXCEPT
- {
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- return local_thread_info.get() && (detail::win32::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0);
- }
-
-#endif
-
- unsigned thread::hardware_concurrency() BOOST_NOEXCEPT
- {
- detail::win32::system_info info;
- detail::win32::get_system_info(&info);
- return info.dwNumberOfProcessors;
- }
-
- unsigned thread::physical_concurrency() BOOST_NOEXCEPT
- {
- // a bit too strict: Windows XP with SP3 would be sufficient
-#if BOOST_PLAT_WINDOWS_RUNTIME \
- || ( BOOST_USE_WINAPI_VERSION <= BOOST_WINAPI_VERSION_WINXP ) \
- || ( ( defined(__MINGW32__) && !defined(__MINGW64__) ) && _WIN32_WINNT < 0x0600)
- return 0;
-#else
- unsigned cores = 0;
- DWORD size = 0;
-
- GetLogicalProcessorInformation(NULL, &size);
- if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
- return 0;
-
- std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> buffer(size);
- if (GetLogicalProcessorInformation(&buffer.front(), &size) == FALSE)
- return 0;
-
- const size_t Elements = size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
-
- for (size_t i = 0; i < Elements; ++i) {
- if (buffer[i].Relationship == RelationProcessorCore)
- ++cores;
- }
- return cores;
-#endif
- }
-
- thread::native_handle_type thread::native_handle()
- {
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(!local_thread_info)
- {
- return detail::win32::invalid_handle_value;
- }
-#if BOOST_PLAT_WINDOWS_RUNTIME
- // There is no 'real' Win32 handle so we return a handle that at least can be waited on.
- return local_thread_info->thread_handle.waitable_handle();
-#else
- return (detail::win32::handle)local_thread_info->thread_handle;
-#endif
- }
-
- detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const
- {
- return thread_info;
- }
-
- namespace this_thread
- {
- namespace
- {
- LARGE_INTEGER get_due_time(detail::timeout const& target_time)
- {
- LARGE_INTEGER due_time={{0,0}};
- if(target_time.relative)
- {
- detail::win32::ticks_type const elapsed_milliseconds=detail::win32::GetTickCount64_()()-target_time.start;
- LONGLONG const remaining_milliseconds=(target_time.milliseconds-elapsed_milliseconds);
- LONGLONG const hundred_nanoseconds_in_one_millisecond=10000;
-
- if(remaining_milliseconds>0)
- {
- due_time.QuadPart=-(remaining_milliseconds*hundred_nanoseconds_in_one_millisecond);
- }
- }
- else
- {
- SYSTEMTIME target_system_time={0,0,0,0,0,0,0,0};
- target_system_time.wYear=target_time.abs_time.date().year();
- target_system_time.wMonth=target_time.abs_time.date().month();
- target_system_time.wDay=target_time.abs_time.date().day();
- target_system_time.wHour=(WORD)target_time.abs_time.time_of_day().hours();
- target_system_time.wMinute=(WORD)target_time.abs_time.time_of_day().minutes();
- target_system_time.wSecond=(WORD)target_time.abs_time.time_of_day().seconds();
-
- if(!SystemTimeToFileTime(&target_system_time,((FILETIME*)&due_time)))
- {
- due_time.QuadPart=0;
- }
- else
- {
- long const hundred_nanoseconds_in_one_second=10000000;
- posix_time::time_duration::tick_type const ticks_per_second=
- target_time.abs_time.time_of_day().ticks_per_second();
- if(ticks_per_second>hundred_nanoseconds_in_one_second)
- {
- posix_time::time_duration::tick_type const
- ticks_per_hundred_nanoseconds=
- ticks_per_second/hundred_nanoseconds_in_one_second;
- due_time.QuadPart+=
- target_time.abs_time.time_of_day().fractional_seconds()/
- ticks_per_hundred_nanoseconds;
- }
- else
- {
- due_time.QuadPart+=
- target_time.abs_time.time_of_day().fractional_seconds()*
- (hundred_nanoseconds_in_one_second/ticks_per_second);
- }
- }
- }
- return due_time;
- }
- }
-
-#ifndef UNDER_CE
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- namespace detail_
- {
- typedef struct _REASON_CONTEXT {
- ULONG Version;
- DWORD Flags;
- union {
- LPWSTR SimpleReasonString;
- struct {
- HMODULE LocalizedReasonModule;
- ULONG LocalizedReasonId;
- ULONG ReasonStringCount;
- LPWSTR *ReasonStrings;
- } Detailed;
- } Reason;
- } REASON_CONTEXT, *PREASON_CONTEXT;
- //static REASON_CONTEXT default_reason_context={0/*POWER_REQUEST_CONTEXT_VERSION*/, 0x00000001/*POWER_REQUEST_CONTEXT_SIMPLE_STRING*/, (LPWSTR)L"generic"};
- typedef BOOL (WINAPI *setwaitabletimerex_t)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, PREASON_CONTEXT, ULONG);
- static inline BOOL WINAPI SetWaitableTimerEx_emulation(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
- {
- return SetWaitableTimer(hTimer, lpDueTime, lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, FALSE);
- }
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 6387) // MSVC sanitiser warns that GetModuleHandleA() might fail
-#endif
- static inline setwaitabletimerex_t SetWaitableTimerEx()
- {
- static setwaitabletimerex_t setwaitabletimerex_impl;
- if(setwaitabletimerex_impl)
- return setwaitabletimerex_impl;
- void (*addr)()=(void (*)()) GetProcAddress(
-#if !defined(BOOST_NO_ANSI_APIS)
- GetModuleHandleA("KERNEL32.DLL"),
-#else
- GetModuleHandleW(L"KERNEL32.DLL"),
-#endif
- "SetWaitableTimerEx");
- if(addr)
- setwaitabletimerex_impl=(setwaitabletimerex_t) addr;
- else
- setwaitabletimerex_impl=&SetWaitableTimerEx_emulation;
- return setwaitabletimerex_impl;
- }
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
- }
-#endif
-#endif
- bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time)
- {
- detail::win32::handle handles[4]={0};
- unsigned handle_count=0;
- unsigned wait_handle_index=~0U;
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- unsigned interruption_index=~0U;
-#endif
- unsigned timeout_index=~0U;
- if(handle_to_wait_for!=detail::win32::invalid_handle_value)
- {
- wait_handle_index=handle_count;
- handles[handle_count++]=handle_to_wait_for;
- }
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- if(detail::get_current_thread_data() && detail::get_current_thread_data()->interruption_enabled)
- {
- interruption_index=handle_count;
- handles[handle_count++]=detail::get_current_thread_data()->interruption_handle;
- }
-#endif
- detail::win32::handle_manager timer_handle;
-
-#ifndef UNDER_CE
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- // Preferentially use coalescing timers for better power consumption and timer accuracy
- if(!target_time.is_sentinel())
- {
- detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds();
- timer_handle=CreateWaitableTimer(NULL,false,NULL);
- if(timer_handle!=0)
- {
- ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26
- if(time_left.milliseconds/20>tolerable) // 5%
- tolerable=time_left.milliseconds/20;
- LARGE_INTEGER due_time=get_due_time(target_time);
- //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0;
- bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0;
- if(set_time_succeeded)
- {
- timeout_index=handle_count;
- handles[handle_count++]=timer_handle;
- }
- }
- }
-#endif
-#endif
-
- bool const using_timer=timeout_index!=~0u;
- detail::timeout::remaining_time time_left(0);
-
- do
- {
- if(!using_timer)
- {
- time_left=target_time.remaining_milliseconds();
- }
-
- if(handle_count)
- {
- unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
- if(notified_index<handle_count)
- {
- if(notified_index==wait_handle_index)
- {
- return true;
- }
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- else if(notified_index==interruption_index)
- {
- detail::win32::ResetEvent(detail::get_current_thread_data()->interruption_handle);
- throw thread_interrupted();
- }
-#endif
- else if(notified_index==timeout_index)
- {
- return false;
- }
- }
- }
- else
- {
- detail::win32::sleep(time_left.milliseconds);
- }
- if(target_time.relative)
- {
- target_time.milliseconds-=detail::timeout::max_non_infinite_wait;
- }
- }
- while(time_left.more);
- return false;
- }
-
- namespace no_interruption_point
- {
- bool non_interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time)
- {
- detail::win32::handle handles[3]={0};
- unsigned handle_count=0;
- unsigned wait_handle_index=~0U;
- unsigned timeout_index=~0U;
- if(handle_to_wait_for!=detail::win32::invalid_handle_value)
- {
- wait_handle_index=handle_count;
- handles[handle_count++]=handle_to_wait_for;
- }
- detail::win32::handle_manager timer_handle;
-
-#ifndef UNDER_CE
-#if !BOOST_PLAT_WINDOWS_RUNTIME
- // Preferentially use coalescing timers for better power consumption and timer accuracy
- if(!target_time.is_sentinel())
- {
- detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds();
- timer_handle=CreateWaitableTimer(NULL,false,NULL);
- if(timer_handle!=0)
- {
- ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26
- if(time_left.milliseconds/20>tolerable) // 5%
- tolerable=time_left.milliseconds/20;
- LARGE_INTEGER due_time=get_due_time(target_time);
- //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0;
- bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0;
- if(set_time_succeeded)
- {
- timeout_index=handle_count;
- handles[handle_count++]=timer_handle;
- }
- }
- }
-#endif
-#endif
-
- bool const using_timer=timeout_index!=~0u;
- detail::timeout::remaining_time time_left(0);
-
- do
- {
- if(!using_timer)
- {
- time_left=target_time.remaining_milliseconds();
- }
-
- if(handle_count)
- {
- unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
- if(notified_index<handle_count)
- {
- if(notified_index==wait_handle_index)
- {
- return true;
- }
- else if(notified_index==timeout_index)
- {
- return false;
- }
- }
- }
- else
- {
- detail::win32::sleep(time_left.milliseconds);
- }
- if(target_time.relative)
- {
- target_time.milliseconds-=detail::timeout::max_non_infinite_wait;
- }
- }
- while(time_left.more);
- return false;
- }
- }
-
- thread::id get_id() BOOST_NOEXCEPT
- {
-#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
-#if BOOST_PLAT_WINDOWS_RUNTIME
- detail::thread_data_base* current_thread_data(detail::get_current_thread_data());
- if (current_thread_data)
- {
- return current_thread_data->id;
- }
-#endif
- return detail::win32::GetCurrentThreadId();
-#else
- return thread::id(get_or_make_current_thread_data());
-#endif
- }
-
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- void interruption_point()
- {
- if(interruption_enabled() && interruption_requested())
- {
- detail::win32::ResetEvent(detail::get_current_thread_data()->interruption_handle);
- throw thread_interrupted();
- }
- }
-
- bool interruption_enabled() BOOST_NOEXCEPT
- {
- return detail::get_current_thread_data() && detail::get_current_thread_data()->interruption_enabled;
- }
-
- bool interruption_requested() BOOST_NOEXCEPT
- {
- return detail::get_current_thread_data() && (detail::win32::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0);
- }
-#endif
-
- void yield() BOOST_NOEXCEPT
- {
- detail::win32::sleep(0);
- }
-
-#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- disable_interruption::disable_interruption() BOOST_NOEXCEPT:
- interruption_was_enabled(interruption_enabled())
- {
- if(interruption_was_enabled)
- {
- detail::get_current_thread_data()->interruption_enabled=false;
- }
- }
-
- disable_interruption::~disable_interruption() BOOST_NOEXCEPT
- {
- if(detail::get_current_thread_data())
- {
- detail::get_current_thread_data()->interruption_enabled=interruption_was_enabled;
- }
- }
-
- restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
- {
- if(d.interruption_was_enabled)
- {
- detail::get_current_thread_data()->interruption_enabled=true;
- }
- }
-
- restore_interruption::~restore_interruption() BOOST_NOEXCEPT
- {
- if(detail::get_current_thread_data())
- {
- detail::get_current_thread_data()->interruption_enabled=false;
- }
- }
-#endif
- }
-
- namespace detail
- {
- void add_thread_exit_function(thread_exit_function_base* func)
- {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- thread_exit_callback_node* const new_node=
- heap_new<thread_exit_callback_node>(
- func,current_thread_data->thread_exit_callbacks);
- current_thread_data->thread_exit_callbacks=new_node;
- }
-
- tss_data_node* find_tss_data(void const* key)
- {
- detail::thread_data_base* const current_thread_data(get_current_thread_data());
- if(current_thread_data)
- {
- std::map<void const*,tss_data_node>::iterator current_node=
- current_thread_data->tss_data.find(key);
- if(current_node!=current_thread_data->tss_data.end())
- {
- return &current_node->second;
- }
- }
- return NULL;
- }
-
- void* get_tss_data(void const* key)
- {
- if(tss_data_node* const current_node=find_tss_data(key))
- {
- return current_node->value;
- }
- return NULL;
- }
-
- void add_new_tss_node(void const* key,
- boost::shared_ptr<tss_cleanup_function> func,
- void* tss_data)
- {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data)));
- }
-
- void erase_tss_node(void const* key)
- {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- current_thread_data->tss_data.erase(key);
- }
-
- void set_tss_data(void const* key,
- boost::shared_ptr<tss_cleanup_function> func,
- void* tss_data,bool cleanup_existing)
- {
- if(tss_data_node* const current_node=find_tss_data(key))
- {
- if(cleanup_existing && current_node->func && (current_node->value!=0))
- {
- (*current_node->func)(current_node->value);
- }
- if(func || (tss_data!=0))
- {
- current_node->func=func;
- current_node->value=tss_data;
- }
- else
- {
- erase_tss_node(key);
- }
- }
- else if(func || (tss_data!=0))
- {
- add_new_tss_node(key,func,tss_data);
- }
- }
- }
-
- BOOST_THREAD_DECL void __cdecl on_process_enter()
- {}
-
- BOOST_THREAD_DECL void __cdecl on_thread_enter()
- {}
-
- BOOST_THREAD_DECL void __cdecl on_process_exit()
- {
- boost::cleanup_tls_key();
- }
-
- BOOST_THREAD_DECL void __cdecl on_thread_exit()
- {
- boost::run_thread_exit_callbacks();
- }
-
- BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
- {
- detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
- if(current_thread_data)
- {
- current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
- }
- }
-//namespace detail {
-//
-// void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
-// {
-// detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
-// if(current_thread_data)
-// {
-// current_thread_data->make_ready_at_thread_exit(as);
-// }
-// }
-//}
-}
-
diff --git a/boost/libs/thread/src/win32/tss_dll.cpp b/boost/libs/thread/src/win32/tss_dll.cpp
deleted file mode 100644
index cd71933c..00000000
--- a/boost/libs/thread/src/win32/tss_dll.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-// (C) Copyright Michael Glassford 2004.
-// Use, modification and distribution are subject to 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)
-
-#include <boost/detail/winapi/config.hpp>
-#include <boost/thread/detail/config.hpp>
-
-
-#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL)
-
- #include <boost/thread/detail/tss_hooks.hpp>
-
- #include <windows.h>
-
- #if defined(__BORLANDC__)
- extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
- #elif defined(_WIN32_WCE)
- extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
- #else
- extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
- #endif
- {
- switch(dwReason)
- {
- case DLL_PROCESS_ATTACH:
- {
- boost::on_process_enter();
- boost::on_thread_enter();
- break;
- }
-
- case DLL_THREAD_ATTACH:
- {
- boost::on_thread_enter();
- break;
- }
-
- case DLL_THREAD_DETACH:
- {
- boost::on_thread_exit();
- break;
- }
-
- case DLL_PROCESS_DETACH:
- {
- boost::on_thread_exit();
- boost::on_process_exit();
- break;
- }
- }
-
- return TRUE;
- }
-
-namespace boost
-{
- void tss_cleanup_implemented()
- {
- /*
- This function's sole purpose is to cause a link error in cases where
- automatic tss cleanup is not implemented by Boost.Threads as a
- reminder that user code is responsible for calling the necessary
- functions at the appropriate times (and for implementing an a
- tss_cleanup_implemented() function to eliminate the linker's
- missing symbol error).
-
- If Boost.Threads later implements automatic tss cleanup in cases
- where it currently doesn't (which is the plan), the duplicate
- symbol error will warn the user that their custom solution is no
- longer needed and can be removed.
- */
- }
-}
-
-#else //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL)
-
-#ifdef _MSC_VER
-// Prevent LNK4221 warning with link=static
-namespace boost { namespace link_static_warning_inhibit {
- extern __declspec(dllexport) void foo() { }
-} }
-#endif
-
-#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL)
diff --git a/boost/libs/thread/src/win32/tss_pe.cpp b/boost/libs/thread/src/win32/tss_pe.cpp
deleted file mode 100644
index 841f98b8..00000000
--- a/boost/libs/thread/src/win32/tss_pe.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-// $Id$
-// (C) Copyright Aaron W. LaFramboise, Roland Schwarz, Michael Glassford 2004.
-// (C) Copyright 2007 Roland Schwarz
-// (C) Copyright 2007 Anthony Williams
-// (C) Copyright 2007 David Deakins
-// Use, modification and distribution are subject to 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)
-
-#include <boost/detail/winapi/config.hpp>
-#include <boost/thread/detail/config.hpp>
-
-#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB)
-
-#if (defined(__MINGW32__) && !defined(_WIN64)) || defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR)
-
-#include <boost/thread/detail/tss_hooks.hpp>
-
-#include <windows.h>
-
-#include <cstdlib>
-
-namespace boost
-{
- void tss_cleanup_implemented() {}
-}
-
-namespace {
- void NTAPI on_tls_callback(void* , DWORD dwReason, PVOID )
- {
- switch (dwReason)
- {
- case DLL_THREAD_DETACH:
- {
- boost::on_thread_exit();
- break;
- }
- }
- }
-}
-
-#if defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION >3) || \
- ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18))
-extern "C"
-{
- PIMAGE_TLS_CALLBACK __crt_xl_tls_callback__ __attribute__ ((section(".CRT$XLB"))) = on_tls_callback;
-}
-#else
-extern "C" {
-
- void (* after_ctors )() __attribute__((section(".ctors"))) = boost::on_process_enter;
- void (* before_dtors)() __attribute__((section(".dtors"))) = boost::on_thread_exit;
- void (* after_dtors )() __attribute__((section(".dtors.zzz"))) = boost::on_process_exit;
-
- ULONG __tls_index__ = 0;
- char __tls_end__ __attribute__((section(".tls$zzz"))) = 0;
- char __tls_start__ __attribute__((section(".tls"))) = 0;
-
-
- PIMAGE_TLS_CALLBACK __crt_xl_start__ __attribute__ ((section(".CRT$XLA"))) = 0;
- PIMAGE_TLS_CALLBACK __crt_xl_end__ __attribute__ ((section(".CRT$XLZ"))) = 0;
-}
-extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata$T"))) =
-{
- (DWORD) &__tls_start__,
- (DWORD) &__tls_end__,
- (DWORD) &__tls_index__,
- (DWORD) (&__crt_xl_start__+1),
- (DWORD) 0,
- (DWORD) 0
-};
-#endif
-
-
-#elif defined(_MSC_VER) && !defined(UNDER_CE)
-
- #include <boost/thread/detail/tss_hooks.hpp>
-
- #include <stdlib.h>
-
- #include <windows.h>
-
-
-// _pRawDllMainOrig can be defined by including boost/thread/win32/mfc_thread_init.hpp
-// into your dll; it ensures that MFC-Dll-initialization will be done properly
-// The following code is adapted from the MFC-Dll-init code
-/*
- * _pRawDllMainOrig MUST be an extern const variable, which will be aliased to
- * _pDefaultRawDllMainOrig if no real user definition is present, thanks to the
- * alternatename directive.
- */
-
-// work at least with _MSC_VER 1500 (MSVC++ 9.0, VS 2008)
-#if (_MSC_VER >= 1500)
-
-extern "C" {
-extern BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID);
-extern BOOL (WINAPI * const _pDefaultRawDllMainOrig)(HANDLE, DWORD, LPVOID) = NULL;
-#if defined (_M_IX86)
-#pragma comment(linker, "/alternatename:__pRawDllMainOrig=__pDefaultRawDllMainOrig")
-#elif defined (_M_X64) || defined (_M_ARM)
-#pragma comment(linker, "/alternatename:_pRawDllMainOrig=_pDefaultRawDllMainOrig")
-#else /* defined (_M_X64) || defined (_M_ARM) */
-#error Unsupported platform
-#endif /* defined (_M_X64) || defined (_M_ARM) */
-}
-
-#endif
-
-
-
-
- //Definitions required by implementation
-
- #if (_MSC_VER < 1300) || (_MSC_VER > 1900) // 1300 == VC++ 7.0, 1900 == VC++ 14.0
- typedef void (__cdecl *_PVFV)();
- #define INIRETSUCCESS
- #define PVAPI void __cdecl
- #else
- typedef int (__cdecl *_PVFV)();
- #define INIRETSUCCESS 0
- #define PVAPI int __cdecl
- #endif
-
- typedef void (NTAPI* _TLSCB)(HINSTANCE, DWORD, PVOID);
-
- //Symbols for connection to the runtime environment
-
- extern "C"
- {
- extern DWORD _tls_used; //the tls directory (located in .rdata segment)
- extern _TLSCB __xl_a[], __xl_z[]; //tls initializers */
- }
-
- namespace
- {
- //Forward declarations
-
- static PVAPI on_tls_prepare();
- static PVAPI on_process_init();
- static PVAPI on_process_term();
- static void NTAPI on_tls_callback(HINSTANCE, DWORD, PVOID);
-
- //The .CRT$Xxx information is taken from Codeguru:
- //http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c6945__2/
-
-#if (_MSC_VER >= 1400)
-#pragma section(".CRT$XIU",long,read)
-#pragma section(".CRT$XCU",long,read)
-#pragma section(".CRT$XTU",long,read)
-#pragma section(".CRT$XLC",long,read)
- __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback;
- __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare;
- __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init;
- __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term;
-#else
- #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0
- # pragma data_seg(push, old_seg)
- #endif
- //Callback to run tls glue code first.
- //I don't think it is necessary to run it
- //at .CRT$XIB level, since we are only
- //interested in thread detachement. But
- //this could be changed easily if required.
-
- #pragma data_seg(".CRT$XIU")
- static _PVFV p_tls_prepare = on_tls_prepare;
- #pragma data_seg()
-
- //Callback after all global ctors.
-
- #pragma data_seg(".CRT$XCU")
- static _PVFV p_process_init = on_process_init;
- #pragma data_seg()
-
- //Callback for tls notifications.
-
- #pragma data_seg(".CRT$XLB")
- _TLSCB p_thread_callback = on_tls_callback;
- #pragma data_seg()
- //Callback for termination.
-
- #pragma data_seg(".CRT$XTU")
- static _PVFV p_process_term = on_process_term;
- #pragma data_seg()
- #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0
- # pragma data_seg(pop, old_seg)
- #endif
-#endif
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4189)
-#endif
-
- PVAPI on_tls_prepare()
- {
- //The following line has an important side effect:
- //if the TLS directory is not already there, it will
- //be created by the linker. In other words, it forces a tls
- //directory to be generated by the linker even when static tls
- //(i.e. __declspec(thread)) is not used.
- //The volatile should prevent the optimizer
- //from removing the reference.
-
- DWORD volatile dw = _tls_used;
-
- #if (_MSC_VER < 1300) // 1300 == VC++ 7.0
- _TLSCB* pfbegin = __xl_a;
- _TLSCB* pfend = __xl_z;
- _TLSCB* pfdst = pfbegin;
- //pfdst = (_TLSCB*)_tls_used.AddressOfCallBacks;
-
- //The following loop will merge the address pointers
- //into a contiguous area, since the tlssup code seems
- //to require this (at least on MSVC 6)
-
- while (pfbegin < pfend)
- {
- if (*pfbegin != 0)
- {
- *pfdst = *pfbegin;
- ++pfdst;
- }
- ++pfbegin;
- }
-
- *pfdst = 0;
- #endif
-
- return INIRETSUCCESS;
- }
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
- PVAPI on_process_init()
- {
- //Schedule on_thread_exit() to be called for the main
- //thread before destructors of global objects have been
- //called.
-
- //It will not be run when 'quick' exiting the
- //library; however, this is the standard behaviour
- //for destructors of global objects, so that
- //shouldn't be a problem.
-
- atexit(boost::on_thread_exit);
-
- //Call Boost process entry callback here
-
- boost::on_process_enter();
-
- return INIRETSUCCESS;
- }
-
- PVAPI on_process_term()
- {
- boost::on_process_exit();
- return INIRETSUCCESS;
- }
-
- void NTAPI on_tls_callback(HINSTANCE /*h*/, DWORD dwReason, PVOID /*pv*/)
- {
- switch (dwReason)
- {
- case DLL_THREAD_DETACH:
- boost::on_thread_exit();
- break;
- }
- }
-
-#if (_MSC_VER >= 1500)
- BOOL WINAPI dll_callback(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
-#else
- BOOL WINAPI dll_callback(HANDLE, DWORD dwReason, LPVOID)
-#endif
- {
- switch (dwReason)
- {
- case DLL_THREAD_DETACH:
- boost::on_thread_exit();
- break;
- case DLL_PROCESS_DETACH:
- boost::on_process_exit();
- break;
- }
-
-#if (_MSC_VER >= 1500)
- if( _pRawDllMainOrig )
- {
- return _pRawDllMainOrig(hInstance, dwReason, lpReserved);
- }
-#endif
- return true;
- }
- } //namespace
-
-extern "C"
-{
- extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback;
-}
-namespace boost
-{
- void tss_cleanup_implemented()
- {
- /*
- This function's sole purpose is to cause a link error in cases where
- automatic tss cleanup is not implemented by Boost.Threads as a
- reminder that user code is responsible for calling the necessary
- functions at the appropriate times (and for implementing an a
- tss_cleanup_implemented() function to eliminate the linker's
- missing symbol error).
-
- If Boost.Threads later implements automatic tss cleanup in cases
- where it currently doesn't (which is the plan), the duplicate
- symbol error will warn the user that their custom solution is no
- longer needed and can be removed.
- */
- }
-}
-
-#endif //defined(_MSC_VER) && !defined(UNDER_CE)
-
-#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB)