2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-03 09:42:16 +00:00

Compare commits

...

57 Commits

Author SHA1 Message Date
Peter Dimov
aec18d337f Update CMakeLists.txt 2023-10-15 16:17:36 +03:00
Peter Dimov
54a28e4d54 Remove MinGW (non w64) from Appveyor 2023-10-14 18:51:29 +03:00
Peter Dimov
9d73a06e06 Add missing include 2023-10-14 04:12:09 +03:00
Peter Dimov
527a56f242 Remove dependency on Iterator 2023-10-14 03:52:02 +03:00
Peter Dimov
f1003a9a5f Remove dependency on LexicalCast 2023-10-14 03:25:40 +03:00
Peter Dimov
710e6fd278 Add boost/thread/detail/string_to_unsigned.hpp 2023-10-14 03:21:14 +03:00
Peter Dimov
5cbc8db036 Eliminate dependency on Algorithm 2023-10-14 02:59:25 +03:00
Peter Dimov
caa7c111d2 Add boost/thread/detail/string_trim.hpp 2023-10-14 02:53:15 +03:00
Peter Dimov
a513e53043 Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83756 2023-10-14 01:42:25 +03:00
Peter Dimov
5fb09cd1c1 std::make_unique is C++14 2023-10-13 21:26:18 +03:00
Peter Dimov
515d95c441 Remove workarounds from csbl headers to reduce dependencies 2023-10-13 19:46:06 +03:00
Peter Dimov
32d8199b6c Update meta/libraries.json 2023-10-13 19:24:23 +03:00
Peter Dimov
d0264d6813 Merge branch 'develop' into feature/appveyor 2023-09-13 13:30:52 +03:00
Peter Dimov
cf06d84362 Merge pull request #394 from Lastique/patch-6
Update declval.hpp include
2023-09-13 12:36:52 +03:00
Peter Dimov
ccc5e3142c Further increase test timeout 2023-09-13 11:08:17 +03:00
Peter Dimov
97060416f1 Remove MinGW from Appveyor because of an internal compiler error 2023-09-13 10:06:26 +03:00
Peter Dimov
88e32fd1ac Add cxxstd=11 to MinGW on Appveyor 2023-09-13 01:55:20 +03:00
Andrey Semashev
5f41e68838 Update declval.hpp include.
The header is part of Boost.TypeTraits, so use the appropriate header path.
2023-09-11 21:15:28 +03:00
Peter Dimov
7d570f70d8 Remove msvc-12.0 from Appveyor 2023-09-11 19:32:44 +03:00
Peter Dimov
e62d29f917 Merge branch 'feature/pr-393' into develop 2023-09-11 19:14:36 +03:00
Peter Dimov
09f01fbb05 Merge branch 'invoke_swap' of https://github.com/Flamefire/thread into feature/pr-393 2023-09-11 17:06:57 +03:00
Peter Dimov
fadb514c71 Merge branch 'win32-clang-tsa-annotations' of https://github.com/Kojoley/thread into feature/pr-386 2023-09-11 16:58:12 +03:00
Peter Dimov
30dcb6dcbc Update ci.yml 2023-09-11 15:58:17 +03:00
Alexander Grund
27cb703930 Use boost::core::invoke_swap instead of deprecated boost::swap 2023-09-11 09:30:45 +02:00
Nikita Kniazev
d56f3f25ad Win32 Clang TSA annotations. Fixes #321 2023-04-23 02:03:50 +03:00
Peter Dimov
52b62ee7b0 Update ci.yml 2023-01-01 03:23:17 +02:00
Peter Dimov
78af23ca14 Remove tabs 2022-12-31 20:01:31 +02:00
Peter Dimov
743d19d7d3 Update ci.yml 2022-07-05 21:47:52 +03:00
Peter Dimov
7f7faf234d Merge branch 'develop' of https://github.com/mbs-c/thread into feature/pr-324 2022-07-05 20:50:14 +03:00
Peter Dimov
1de55fceda Fix test_366_4.cpp 2022-05-14 17:26:50 +03:00
Peter Dimov
8db325363b Disable interruptions in ~thread_guard, ~scoped_thread, ~strict_scoped_thread (refs #366, #367, #369) 2022-05-13 21:49:14 +03:00
Peter Dimov
f71e0f1645 Add test cases for issue #366 (also see comments in #367 and #369) 2022-05-13 21:41:54 +03:00
Peter Dimov
7f36ea346f Merge pull request #336 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-10-26 16:59:32 +03:00
Peter Dimov
660f293809 Remove all Windows jobs from ci.yml; the timeouts aren't sufficient and adjusting them all is too much work 2021-10-26 07:18:50 +03:00
Peter Dimov
d4b81d83f7 Remove mingw job; it's hopeless 2021-10-26 05:48:12 +03:00
Peter Dimov
e4d16eb4d9 Trim Windows jobs as they take too long 2021-10-26 05:47:43 +03:00
Peter Dimov
28a0a19cf0 Switch g++-5 to C++11 2021-10-26 05:07:37 +03:00
Peter Dimov
fca97a8826 Adjust warning suppression 2021-10-26 05:06:05 +03:00
Peter Dimov
48e639b124 Add .github/workflows 2021-10-26 03:53:10 +03:00
Peter Dimov
51f3e163b3 Merge branch 'develop' of https://github.com/Romain-Geissler-1A/thread into feature/pr-354 2021-10-26 02:00:43 +03:00
Peter Dimov
6fca28bfed Merge pull request #356 from Dani-Hub/Tolerable-delay-in-interruptible_wait-on-Win32-is-too-long-2
#348 Tolerable delay in interruptible_wait on Win32 is too long
2021-08-27 20:16:59 +03:00
Daniel Krügler
636e4a869c #348 Tolerable delay in interruptible_wait on Win32 is too long
Ensure that SetWaitableTimerEx's TolerableDelay parameter is clamped between 32 and 1000 ms when computing the 5% deviation.
2021-08-17 18:50:24 +02:00
Romain Geissler
f9d0e594d4 Fix -Wsign-compare warning with glibc 2.34 on Linux platforms.
In file included from /data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/thread_only.hpp:17,
                 from /data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/thread.hpp:12,
                 from src/GetTest.cpp:12:
/data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/pthread/thread_data.hpp: In member function 'void boost::thread_attributes::set_stack_size(std::size_t)':
/data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/pthread/thread_data.hpp:61:19: error: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'long int' [-Werror=sign-compare]
   61 |           if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN;
      |                   ^
2021-08-10 14:22:28 +00:00
Peter Dimov
23e7658347 Add a configuration option for threadapi=pthread/win32, set the default properly on Cygwin 2021-05-30 06:52:40 +03:00
Peter Dimov
190ec21523 Define the macros specific to Boost.Thread in CMakeLists.txt 2021-05-28 02:34:10 +03:00
Peter Dimov
f17d23ac2a Link Boost::thread to Threads::Threads 2021-05-25 21:37:15 +03:00
Peter Dimov
4abafccff4 Add CMakeLists.txt 2021-03-18 18:22:17 +02:00
Edward Diener
c55e0952ee [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-21 16:22:48 -05:00
Peter Dimov
409c98f8b7 Merge pull request #317 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74
2020-08-25 17:23:02 +03:00
Peter Dimov
573296557a Do not define boost::make_exception_ptr, as it's defined in Boost.Exception 2020-08-11 21:26:46 +03:00
Moritz Baumann
4bc126fc37 Update calling convention macros in thread_primitives.cpp 2020-08-11 10:07:39 +02:00
Peter Dimov
96cd717b33 Add msvc-14.2/release to Appveyor 2020-07-03 19:49:33 +03:00
Nikita Kniazev
7afa3e9fd4 Fixed optimized away hooks. Fixes #316
MSVC learned to not emit unreferenced symbols with internal linkage and the
hooks were defined in unnamed namespace which forces internal linkage, even if
you mark a variable `extern`.

Since Boost does not have a stable ABI, does not mangle the namespace with
the version, and the hooks are in `boost` namespace (`boost::on_*`) -- there is
no point in trying to hide some symbols because mixing different versions of
boost static libraries will not work already.

I also renamed the `__xl_ca` variable for consistency and because using double
underscored identifiers is forbidden. (`[lex.name]/3`)

The `extern const` is for verbosity and because they are indeed const (it is
done via pragma already).
2020-06-14 17:13:15 +03:00
Edward Diener
f5bf0951be Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero. 2020-04-25 22:38:32 -04:00
Edward Diener
1fceaebe00 Merge branch 'develop' of https://github.com/eldiener/thread into cppbuilder 2020-04-18 19:14:00 -04:00
Edward Diener
30f0ec41fe The corrected DLL entry point for the Embarcadero clang-based compilers. 2020-04-18 17:21:30 -04:00
Edward Diener
1c28a63e26 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-31 22:29:17 -04:00
56 changed files with 805 additions and 429 deletions

105
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,105 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
os: ubuntu-latest
container: ubuntu:18.04
cxxstd: 11
install: g++-4.8
- toolset: gcc-5
cxxstd: 11
os: ubuntu-latest
container: ubuntu:18.04
install: g++-5
- toolset: gcc-7
os: ubuntu-20.04
install: g++-7
- toolset: gcc-9
os: ubuntu-20.04
- toolset: gcc-11
os: ubuntu-22.04
- toolset: clang
compiler: clang++-15
cxxstd: 20
os: ubuntu-22.04
install: clang-15
- toolset: clang
os: macos-11
cxxstd: 11
- toolset: clang
os: macos-12
cxxstd: 14
- toolset: clang
os: macos-13
cxxstd: 17
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
export CXXSTD=${{matrix.cxxstd}}
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} ${CXXSTD:+cxxstd=$CXXSTD} variant=debug,release

100
CMakeLists.txt Normal file
View File

@@ -0,0 +1,100 @@
# Generated by `boostdep --cmake thread`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8...3.20)
project(boost_thread VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(_default_threadapi pthread)
if(WIN32 AND NOT CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin")
set(_default_threadapi win32)
endif()
set(BOOST_THREAD_THREADAPI ${_default_threadapi} CACHE STRING "Boost.Thread threading API (pthread or win32)")
set_property(CACHE BOOST_THREAD_THREADAPI PROPERTY STRINGS pthread win32)
unset(_default_threadapi)
message(STATUS "Boost.Thread: threading API is ${BOOST_THREAD_THREADAPI}")
if(BOOST_THREAD_THREADAPI STREQUAL win32)
set(THREAD_SOURCES
src/win32/thread.cpp
src/win32/tss_dll.cpp
src/win32/tss_pe.cpp
src/win32/thread_primitives.cpp
src/future.cpp
)
else()
set(THREAD_SOURCES
src/pthread/thread.cpp
src/pthread/once.cpp
src/future.cpp
)
endif()
add_library(boost_thread ${THREAD_SOURCES})
add_library(Boost::thread ALIAS boost_thread)
target_include_directories(boost_thread PUBLIC include)
target_link_libraries(boost_thread
PUBLIC
Boost::assert
Boost::atomic
Boost::bind
Boost::chrono
Boost::concept_check
Boost::config
Boost::container
Boost::container_hash
Boost::core
Boost::date_time
Boost::exception
Boost::function
Boost::io
Boost::move
Boost::optional
Boost::predef
Boost::preprocessor
Boost::smart_ptr
Boost::static_assert
Boost::system
Boost::throw_exception
Boost::tuple
Boost::type_traits
Boost::utility
Boost::winapi
Threads::Threads
)
target_compile_features(boost_thread PUBLIC cxx_std_11)
target_compile_definitions(boost_thread
PUBLIC BOOST_THREAD_NO_LIB
PRIVATE BOOST_THREAD_SOURCE
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_thread PUBLIC BOOST_THREAD_DYN_LINK INTERFACE BOOST_THREAD_USE_DLL PRIVATE BOOST_THREAD_BUILD_DLL)
else()
target_compile_definitions(boost_thread PUBLIC BOOST_THREAD_STATIC_LINK INTERFACE BOOST_THREAD_USE_LIB PRIVATE BOOST_THREAD_BUILD_LIB)
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -18,9 +18,6 @@ image: Visual Studio 2015
environment:
matrix:
- TOOLSET: msvc-12.0
VARIANT: release
- TOOLSET: msvc-14.0
ADDRMD: 32
VARIANT: debug
@@ -32,31 +29,30 @@ environment:
- TOOLSET: msvc-14.2
CXXSTD: 17
ADDRMD: 64
ADDRMD: 32
VARIANT: debug
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: msvc-14.2
ADDRMD: 64
VARIANT: release
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
VARIANT: release
- ADDPATH: C:\mingw\bin;
- ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
VARIANT: debug
# The following configurations fail with
# ./boost/thread/detail/invoke.hpp:101:43: internal compiler error: in gimplify_expr, at gimplify.c:12039
# https://sourceforge.net/p/mingw-w64/bugs/694/
#
# - ADDPATH: C:\cygwin64\bin;
# TOOLSET: gcc
# VARIANT: debug
# - ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
# TOOLSET: gcc
# VARIANT: debug
# - ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
# TOOLSET: gcc
# VARIANT: debug,release
- ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
VARIANT: debug
- ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
TOOLSET: gcc
VARIANT: release
install:
- set GIT_FETCH_JOBS=8

View File

@@ -9,37 +9,14 @@
#ifndef BOOST_CSBL_DEQUE_HPP
#define BOOST_CSBL_DEQUE_HPP
#include <boost/config.hpp>
// MSVC has some trouble instantiating a non_copyable type
//C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(606) : error C2248: 'non_copyable::non_copyable' : cannot access private member declared in class 'non_copyable'
// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(24) : see declaration of 'non_copyable::non_copyable'
// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(23) : see declaration of 'non_copyable'
// C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(605) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)'
// with
// [
// _Ty=non_copyable
// ]
#if defined BOOST_THREAD_USES_BOOST_DEQUE || defined BOOST_NO_CXX11_RVALUE_REFERENCES || (defined _MSC_VER && _MSC_FULL_VER < 180020827)
#ifndef BOOST_THREAD_USES_BOOST_DEQUE
#define BOOST_THREAD_USES_BOOST_DEQUE
#endif
#include <boost/container/deque.hpp>
#else
#include <deque>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_DEQUE
using ::boost::container::deque;
#else
using ::std::deque;
#endif
}
}
#endif // header

View File

@@ -9,24 +9,12 @@
#ifndef BOOST_CSBL_FUNCTIONAL_HPP
#define BOOST_CSBL_FUNCTIONAL_HPP
#include <boost/config.hpp>
#include <functional>
#if defined BOOST_THREAD_USES_BOOST_FUNCTIONAL || defined BOOST_NO_CXX11_HDR_FUNCTIONAL || defined BOOST_NO_CXX11_RVALUE_REFERENCES
#ifndef BOOST_THREAD_USES_BOOST_FUNCTIONAL
#define BOOST_THREAD_USES_BOOST_FUNCTIONAL
#endif
#include <boost/function.hpp>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_FUNCTIONAL
using ::boost::function;
#else
// D.8.1, base (deprecated):
// 20.9.3, reference_wrapper:
// 20.9.4, arithmetic operations:
@@ -42,8 +30,7 @@ namespace boost
// 20.9.11 polymorphic function wrappers:
using ::std::function;
// 20.9.12, hash function primary template:
#endif
}
}
#endif // header

View File

@@ -9,27 +9,14 @@
#ifndef BOOST_CSBL_LIST_HPP
#define BOOST_CSBL_LIST_HPP
#include <boost/config.hpp>
#if defined BOOST_THREAD_USES_BOOST_LIST || defined BOOST_NO_CXX11_RVALUE_REFERENCES
#ifndef BOOST_THREAD_USES_BOOST_LIST
#define BOOST_THREAD_USES_BOOST_LIST
#endif
#include <boost/container/list.hpp>
#else
#include <list>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_LIST
using ::boost::container::list;
#else
using ::std::list;
#endif
}
}
#endif // header

View File

@@ -12,18 +12,7 @@
#include <boost/thread/csbl/memory/config.hpp>
// 20.7.6, allocator argument tag
#if defined BOOST_NO_CXX11_ALLOCATOR
#include <boost/container/scoped_allocator.hpp>
namespace boost
{
namespace csbl
{
using ::boost::container::allocator_arg_t;
using ::boost::container::allocator_arg;
}
}
#else
namespace boost
{
namespace csbl
@@ -32,10 +21,11 @@ namespace boost
using ::std::allocator_arg;
}
}
#endif // BOOST_NO_CXX11_ALLOCATOR
namespace boost
{
using ::boost::csbl::allocator_arg_t;
using ::boost::csbl::allocator_arg;
}
#endif // header

View File

@@ -12,17 +12,7 @@
#include <boost/thread/csbl/memory/config.hpp>
// 20.7.8, allocator traits
#if defined BOOST_NO_CXX11_ALLOCATOR
#include <boost/container/allocator_traits.hpp>
namespace boost
{
namespace csbl
{
using ::boost::container::allocator_traits;
}
}
#else
namespace boost
{
namespace csbl
@@ -30,6 +20,5 @@ namespace boost
using ::std::allocator_traits;
}
}
#endif // BOOST_NO_CXX11_POINTER_TRAITS
#endif // header

View File

@@ -9,8 +9,6 @@
#ifndef BOOST_CSBL_MEMORY_CONFIG_HPP
#define BOOST_CSBL_MEMORY_CONFIG_HPP
#include <boost/config.hpp>
#include <memory>
#endif // header

View File

@@ -14,17 +14,6 @@
// 20.8.1 class template unique_ptr:
// default_delete
#if defined BOOST_NO_CXX11_SMART_PTR
#include <boost/move/unique_ptr.hpp>
namespace boost
{
namespace csbl
{
using ::boost::movelib::default_delete;
}
}
#else
namespace boost
{
namespace csbl
@@ -32,10 +21,5 @@ namespace boost
using ::std::default_delete;
}
}
#endif // defined BOOST_NO_CXX11_SMART_PTR
namespace boost
{
using ::boost::csbl::default_delete;
}
#endif // header

View File

@@ -12,17 +12,7 @@
#include <boost/thread/csbl/memory/config.hpp>
// 20.7.3, pointer traits
#if defined BOOST_NO_CXX11_ALLOCATOR
#include <boost/intrusive/pointer_traits.hpp>
namespace boost
{
namespace csbl
{
using ::boost::intrusive::pointer_traits;
}
}
#else
namespace boost
{
namespace csbl
@@ -30,6 +20,5 @@ namespace boost
using ::std::pointer_traits;
}
}
#endif // BOOST_NO_CXX11_ALLOCATOR
#endif // header

View File

@@ -12,17 +12,7 @@
#include <boost/thread/csbl/memory/config.hpp>
// 20.7.7, uses_allocator
#if defined BOOST_NO_CXX11_ALLOCATOR
#include <boost/container/scoped_allocator.hpp>
namespace boost
{
namespace csbl
{
using ::boost::container::uses_allocator;
}
}
#else
namespace boost
{
namespace csbl
@@ -30,6 +20,5 @@ namespace boost
using ::std::uses_allocator;
}
}
#endif // BOOST_NO_CXX11_POINTER_TRAITS
#endif // header

View File

@@ -11,24 +11,6 @@
#include <boost/thread/csbl/memory/config.hpp>
#if defined BOOST_NO_CXX11_SMART_PTR
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
namespace boost
{
namespace csbl
{
using ::boost::shared_ptr;
using ::boost::make_shared;
}
}
#else
#include <boost/shared_ptr.hpp>
namespace boost
{
namespace csbl
@@ -38,5 +20,4 @@ namespace boost
}
}
#endif
#endif // header

View File

@@ -12,17 +12,15 @@
#define BOOST_CSBL_MEMORY_UNIQUE_PTR_HPP
#include <boost/thread/csbl/memory/config.hpp>
#include <boost/move/unique_ptr.hpp>
#include <boost/move/make_unique.hpp>
#include <boost/smart_ptr/make_unique.hpp>
namespace boost
{
namespace csbl
{
using ::boost::movelib::unique_ptr;
using ::boost::movelib::make_unique;
using ::std::unique_ptr;
using ::boost::make_unique;
}
}
#endif // header

View File

@@ -5,42 +5,18 @@
//
// 2013/10 Vicente J. Botet Escriba
// Creation.
#if 0
#ifndef BOOST_CSBL_QUEUE_HPP
#define BOOST_CSBL_QUEUE_HPP
#include <boost/config.hpp>
// MSVC has some trouble instantiating a non_copyable type
//C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(606) : error C2248: 'non_copyable::non_copyable' : cannot access private member declared in class 'non_copyable'
// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(24) : see declaration of 'non_copyable::non_copyable'
// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(23) : see declaration of 'non_copyable'
// C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(605) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)'
// with
// [
// _Ty=non_copyable
// ]
#if defined BOOST_THREAD_USES_BOOST_QUEUE || defined BOOST_NO_CXX11_RVALUE_REFERENCES || (defined _MSC_VER && _MSC_FULL_VER < 180020827)
#ifndef BOOST_THREAD_USES_BOOST_QUEUE
#define BOOST_THREAD_USES_BOOST_QUEUE
#endif
#include <boost/container/queue.hpp>
#else
#include <queue>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_QUEUE
using ::boost::container::queue;
#else
using ::std::queue;
#endif
}
}
#endif // header
#endif

View File

@@ -9,28 +9,12 @@
#ifndef BOOST_CSBL_TUPLE_HPP
#define BOOST_CSBL_TUPLE_HPP
#include <boost/config.hpp>
#if defined BOOST_THREAD_USES_BOOST_TUPLE || defined BOOST_NO_CXX11_HDR_TUPLE || defined BOOST_NO_CXX11_RVALUE_REFERENCES
#include <boost/tuple/tuple.hpp>
#ifndef BOOST_THREAD_USES_BOOST_TUPLE
#define BOOST_THREAD_USES_BOOST_TUPLE
#endif
#else
#include <tuple>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_TUPLE
using ::boost::tuple;
using ::boost::get;
using ::boost::make_tuple;
//using ::boost::tuple_size;
#else
// 20.4.2, class template tuple:
using ::std::tuple;
using ::std::get;
@@ -42,8 +26,7 @@ namespace boost
// 20.4.2.7, relational operators:
// 20.4.2.8, allocator-related traits
// 20.4.2.9, specialized algorithms:
#endif
}
}
#endif // header

View File

@@ -9,27 +9,14 @@
#ifndef BOOST_CSBL_VECTOR_HPP
#define BOOST_CSBL_VECTOR_HPP
#include <boost/config.hpp>
#if defined BOOST_THREAD_USES_BOOST_VECTOR || defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
#ifndef BOOST_THREAD_USES_BOOST_VECTOR
#define BOOST_THREAD_USES_BOOST_VECTOR
#endif
#include <boost/container/vector.hpp>
#else
#include <vector>
#endif
namespace boost
{
namespace csbl
{
#if defined BOOST_THREAD_USES_BOOST_VECTOR
using ::boost::container::vector;
#else
using ::std::vector;
#endif
}
}
#endif // header

View File

@@ -405,7 +405,7 @@
#define BOOST_THREAD_FUTURE_USES_OPTIONAL
#endif
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
#if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
# pragma warn -8008 // Condition always true/false
# pragma warn -8080 // Identifier declared but never used
# pragma warn -8057 // Parameter never used

View File

@@ -32,6 +32,7 @@
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/is_member_object_pointer.hpp>
#include <boost/type_traits/remove_reference.hpp>
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <functional>
@@ -85,7 +86,13 @@ namespace boost
// bullets 3 and 4
template <class Fp, class A0>
// enable_if avoids
//
// ./boost/thread/detail/invoke.hpp:101:43: internal compiler error: in gimplify_expr, at gimplify.c:12039
// https://sourceforge.net/p/mingw-w64/bugs/694/
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83756
template <class Fp, class A0, class En = typename boost::enable_if<boost::is_member_object_pointer<Fp> >::type>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0)
-> decltype(boost::forward<A0>(a0).*f)
@@ -93,7 +100,7 @@ namespace boost
return boost::forward<A0>(a0).*f;
}
template <class Fp, class A0>
template <class Fp, class A0, class En = typename boost::enable_if<boost::is_member_object_pointer<Fp> >::type>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0)
-> decltype((*boost::forward<A0>(a0)).*f)
@@ -101,7 +108,7 @@ namespace boost
return (*boost::forward<A0>(a0)).*f;
}
template <class R, class Fp, class A0>
template <class R, class Fp, class A0, class En = typename boost::enable_if<boost::is_member_object_pointer<Fp> >::type>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0)
-> decltype(boost::forward<A0>(a0).*f)
@@ -109,7 +116,7 @@ namespace boost
return boost::forward<A0>(a0).*f;
}
template <class R, class Fp, class A0>
template <class R, class Fp, class A0, class En = typename boost::enable_if<boost::is_member_object_pointer<Fp> >::type>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0)
-> decltype((*boost::forward<A0>(a0)).*f)

View File

@@ -0,0 +1,55 @@
#ifndef BOOST_THREAD_DETAIL_STRING_TO_UNSIGNED_HPP_INCLUDED
#define BOOST_THREAD_DETAIL_STRING_TO_UNSIGNED_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <string>
#include <climits>
namespace boost
{
namespace thread_detail
{
inline bool string_to_unsigned( std::string const& s, unsigned& v )
{
v = 0;
if( s.empty() )
{
return false;
}
for( char const* p = s.c_str(); *p; ++p )
{
unsigned char ch = static_cast<unsigned char>( *p );
if( ch < '0' || ch > '9' )
{
return false;
}
if( v > UINT_MAX / 10 )
{
return false;
}
unsigned q = static_cast<unsigned>( ch - '0' );
if( v == UINT_MAX / 10 && q > UINT_MAX % 10 )
{
return false;
}
v = v * 10 + q;
}
return true;
}
} // namespace thread_detail
} // namespace boost
#endif // #ifndef BOOST_THREAD_DETAIL_STRING_TO_UNSIGNED_HPP_INCLUDED

View File

@@ -0,0 +1,29 @@
#ifndef BOOST_THREAD_DETAIL_STRING_TRIM_HPP_INCLUDED
#define BOOST_THREAD_DETAIL_STRING_TRIM_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <string>
namespace boost
{
namespace thread_detail
{
inline std::string string_trim( std::string const& s )
{
std::size_t i = s.find_first_not_of( " \t\r\n" );
if( i == std::string::npos ) return std::string();
std::size_t j = s.find_last_not_of( " \t\r\n" );
return s.substr( i, j + 1 - i );
}
} // namespace thread_detail
} // namespace boost
#endif // #ifndef BOOST_THREAD_DETAIL_STRING_TRIM_HPP_INCLUDED

View File

@@ -601,6 +601,9 @@ namespace boost
class BOOST_SYMBOL_VISIBLE thread::id
{
private:
#if !defined(BOOST_EMBTC)
friend inline
std::size_t
hash_value(const thread::id &v)
@@ -612,6 +615,14 @@ namespace boost
#endif
}
#else
friend
std::size_t
hash_value(const thread::id &v);
#endif
#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
#if defined(BOOST_THREAD_PLATFORM_WIN32)
typedef unsigned int data;
@@ -704,6 +715,21 @@ namespace boost
#endif
#endif
};
#if defined(BOOST_EMBTC)
inline
std::size_t
hash_value(const thread::id &v)
{
#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
return hash_value(v.thread_data);
#else
return hash_value(v.thread_data.get());
#endif
}
#endif
#ifdef BOOST_THREAD_PLATFORM_PTHREAD
inline thread::id thread::get_id() const BOOST_NOEXCEPT

View File

@@ -18,7 +18,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/throw_exception.hpp>
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/config/abi_prefix.hpp>
@@ -105,8 +105,8 @@ namespace boost
void swap(externally_locked& rhs) //BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR)
{
swap(obj_, rhs.obj_);
swap(mtx_, rhs.mtx_);
boost::core::invoke_swap(obj_, rhs.obj_);
boost::core::invoke_swap(mtx_, rhs.mtx_);
}
/**
@@ -245,8 +245,8 @@ namespace boost
void swap(externally_locked& rhs) BOOST_NOEXCEPT
{
swap(obj_, rhs.obj_);
swap(mtx_, rhs.mtx_);
boost::core::invoke_swap(obj_, rhs.obj_);
boost::core::invoke_swap(mtx_, rhs.mtx_);
}
/**
* Requires: The lk parameter must be locking the associated mtx.

View File

@@ -63,7 +63,6 @@ struct shared_state_base {
#include <boost/enable_shared_from_this.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/function.hpp>
#include <boost/next_prior.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>

View File

@@ -17,7 +17,6 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/next_prior.hpp>
#include <boost/scoped_array.hpp>
#include <iterator>
@@ -155,7 +154,9 @@ namespace boost
{
waiter.add(*current);
}
return boost::next(begin, waiter.wait());
std::advance( begin, waiter.wait() );
return begin;
}
}

View File

@@ -58,7 +58,7 @@ namespace boost
std::size_t page_size = ::sysconf( _SC_PAGESIZE);
#endif
#ifdef PTHREAD_STACK_MIN
if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN;
if (size<static_cast<std::size_t>(PTHREAD_STACK_MIN)) size=PTHREAD_STACK_MIN;
#endif
size = ((size+page_size-1)/page_size)*page_size;
int res = pthread_attr_setstacksize(&val_, size);

View File

@@ -14,6 +14,7 @@
#include <boost/thread/detail/move.hpp>
#include <boost/thread/thread_functors.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/detail/thread_interruption.hpp>
#include <boost/config/abi_prefix.hpp>
@@ -85,6 +86,10 @@ namespace boost
*/
~strict_scoped_thread()
{
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
// exceptions from a destructor call std::terminate
boost::this_thread::disable_interruption do_not_disturb;
#endif
CallableThread on_destructor;
on_destructor(t_);
@@ -188,6 +193,10 @@ namespace boost
*/
~scoped_thread()
{
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
// exceptions from a destructor call std::terminate
boost::this_thread::disable_interruption do_not_disturb;
#endif
CallableThread on_destructor;
on_destructor(t_);

View File

@@ -17,8 +17,8 @@
#include <boost/thread/lock_algorithms.hpp>
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/strict_lock.hpp>
#include <boost/core/swap.hpp>
#include <boost/utility/declval.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/type_traits/declval.hpp>
//#include <boost/type_traits.hpp>
//#include <boost/thread/detail/is_nothrow_default_constructible.hpp>
//#if ! defined BOOST_NO_CXX11_HDR_TYPE_TRAITS
@@ -582,7 +582,7 @@ namespace boost
unique_lock<mutex_type> lk1(mtx_, defer_lock);
unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
lock(lk1,lk2);
boost::swap(value_, rhs.value_);
boost::core::invoke_swap(value_, rhs.value_);
}
/**
* Swap with the underlying value type
@@ -592,7 +592,7 @@ namespace boost
void swap(value_type & rhs)
{
strict_lock<mutex_type> lk(mtx_);
boost::swap(value_, rhs);
boost::core::invoke_swap(value_, rhs);
}
/**

View File

@@ -12,6 +12,7 @@
#include <boost/thread/detail/delete.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/thread_functors.hpp>
#include <boost/thread/detail/thread_interruption.hpp>
#include <boost/config/abi_prefix.hpp>
@@ -34,6 +35,10 @@ namespace boost
}
~thread_guard()
{
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
// exceptions from a destructor call std::terminate
boost::this_thread::disable_interruption do_not_disturb;
#endif
CallableThread on_destructor;
on_destructor(t_);

View File

@@ -30,7 +30,7 @@ namespace boost
{
namespace detail
{
struct basic_timed_mutex
struct BOOST_THREAD_CAPABILITY("mutex") basic_timed_mutex
{
BOOST_STATIC_CONSTANT(unsigned char,lock_flag_bit=31);
BOOST_STATIC_CONSTANT(unsigned char,event_set_flag_bit=30);
@@ -62,12 +62,12 @@ namespace boost
}
// Take the lock flag if it's available
bool try_lock() BOOST_NOEXCEPT
bool try_lock() BOOST_NOEXCEPT BOOST_THREAD_TRY_ACQUIRE(true)
{
return !win32::interlocked_bit_test_and_set(&active_count,lock_flag_bit);
}
void lock()
void lock() BOOST_THREAD_ACQUIRE()
{
if(try_lock())
{
@@ -93,7 +93,7 @@ namespace boost
// Loop until the number of waiters has been incremented or we've taken the lock flag
// The loop is necessary since this function may be called by multiple threads simultaneously
void mark_waiting_and_try_lock(long& old_count)
void mark_waiting_and_try_lock(long& old_count) BOOST_THREAD_TRY_ACQUIRE(true)
{
for(;;)
{
@@ -117,7 +117,7 @@ namespace boost
// until we've taken the lock flag and cleared the event set flag and decremented the
// number of waiters
// The loop is necessary since this function may be called by multiple threads simultaneously
void clear_waiting_and_try_lock(long& old_count)
void clear_waiting_and_try_lock(long& old_count) BOOST_THREAD_TRY_ACQUIRE(true)
{
old_count&=~lock_flag_value;
old_count|=event_set_flag_value;
@@ -152,7 +152,7 @@ namespace boost
}
template <typename Clock, typename Timepoint, typename Duration>
bool do_lock_until(Timepoint const& t, Duration const& max)
bool do_lock_until(Timepoint const& t, Duration const& max) BOOST_THREAD_TRY_ACQUIRE(true)
{
if(try_lock())
{
@@ -238,7 +238,7 @@ namespace boost
}
#endif
void unlock()
void unlock() BOOST_THREAD_RELEASE()
{
// Clear the lock flag using atomic addition (works since long is always 32 bits on Windows)
long const old_count=BOOST_INTERLOCKED_EXCHANGE_ADD(&active_count,lock_flag_value);

View File

@@ -145,6 +145,8 @@ namespace boost
{}
virtual ~thread_data_base();
#if !defined(BOOST_EMBTC)
friend void intrusive_ptr_add_ref(thread_data_base * p)
{
BOOST_INTERLOCKED_INCREMENT(&p->count);
@@ -158,6 +160,13 @@ namespace boost
}
}
#else
friend void intrusive_ptr_add_ref(thread_data_base * p);
friend void intrusive_ptr_release(thread_data_base * p);
#endif
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
void interrupt()
{
@@ -180,6 +189,24 @@ namespace boost
}
//#endif
};
#if defined(BOOST_EMBTC)
inline void intrusive_ptr_add_ref(thread_data_base * p)
{
BOOST_INTERLOCKED_INCREMENT(&p->count);
}
inline void intrusive_ptr_release(thread_data_base * p)
{
if(!BOOST_INTERLOCKED_DECREMENT(&p->count))
{
detail::heap_delete(p);
}
}
#endif
BOOST_THREAD_DECL thread_data_base* get_current_thread_data();
typedef boost::intrusive_ptr<detail::thread_data_base> thread_data_ptr;

View File

@@ -10,10 +10,11 @@
"Vicente J. Botet Escriba <vicente.botet -at- wanadoo.fr>"
],
"description":
"Portable C++ multi-threading. C++03, C++11, C++14, C++17.",
"Portable C++ multi-threading. C++11, C++14, C++17.",
"std": [ "proposal" ],
"category": [
"Concurrent", "System"
]
],
"cxxstd": "11"
}
]

View File

@@ -19,6 +19,8 @@
#include <boost/thread/future.hpp>
#include <boost/thread/pthread/pthread_helpers.hpp>
#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
#include <boost/thread/detail/string_trim.hpp>
#include <boost/thread/detail/string_to_unsigned.hpp>
#ifdef __GLIBC__
#include <sys/sysinfo.h>
@@ -33,10 +35,6 @@
#include <vxCpuLib.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>
@@ -535,24 +533,36 @@ namespace boost
if (line.empty())
continue;
vector<string> key_val(2);
boost::split(key_val, line, boost::is_any_of(":"));
std::size_t i = line.find( ':' );
if (key_val.size() != 2)
return hardware_concurrency();
if( i == std::string::npos )
{
return hardware_concurrency();
}
string key = key_val[0];
string value = key_val[1];
boost::trim(key);
boost::trim(value);
std::string key = line.substr( 0, i );
std::string value = line.substr( i+1 );
key = thread_detail::string_trim( key );
value = thread_detail::string_trim( value );
if (key == physical_id) {
current_core_entry.first = boost::lexical_cast<unsigned>(value);
if( !thread_detail::string_to_unsigned( value, current_core_entry.first ) )
{
return hardware_concurrency();
}
continue;
}
if (key == core_id) {
current_core_entry.second = boost::lexical_cast<unsigned>(value);
if( !thread_detail::string_to_unsigned( value, current_core_entry.second ) )
{
return hardware_concurrency();
}
cores.insert(current_core_entry);
continue;
}

View File

@@ -641,9 +641,15 @@ namespace boost
timer_handle=CreateWaitableTimer(NULL,false,NULL);
if(timer_handle!=0)
{
ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26
ULONG const min_tolerable=32; // Empirical testing shows Windows ignores this when <= 26
ULONG const max_tolerable=1000;
ULONG tolerable=min_tolerable;
if(time_left_msec/20>tolerable) // 5%
{
tolerable=static_cast<ULONG>(time_left_msec/20);
if(tolerable>max_tolerable)
tolerable=max_tolerable;
}
LARGE_INTEGER due_time={{0,0}};
if(time_left_msec>0)
{
@@ -733,9 +739,15 @@ namespace boost
timer_handle=CreateWaitableTimer(NULL,false,NULL);
if(timer_handle!=0)
{
ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26
ULONG const min_tolerable=32; // Empirical testing shows Windows ignores this when <= 26
ULONG const max_tolerable=1000;
ULONG tolerable=min_tolerable;
if(time_left_msec/20>tolerable) // 5%
{
tolerable=static_cast<ULONG>(time_left_msec/20);
if(tolerable>max_tolerable)
tolerable=max_tolerable;
}
LARGE_INTEGER due_time={{0,0}};
if(time_left_msec>0)
{

View File

@@ -52,7 +52,7 @@ struct get_tick_count64_state
BOOST_ALIGNMENT(64) static get_tick_count64_state g_state;
//! Artifical implementation of GetTickCount64
ticks_type WINAPI get_tick_count64()
ticks_type BOOST_WINAPI_WINAPI_CC get_tick_count64()
{
uint64_t old_state = g_state.ticks.load(boost::memory_order_acquire);
@@ -67,7 +67,7 @@ ticks_type WINAPI get_tick_count64()
}
//! The function is called periodically in the system thread pool to make sure g_state.ticks is timely updated
void NTAPI refresh_get_tick_count64(boost::winapi::PVOID_, boost::winapi::BOOLEAN_)
void BOOST_WINAPI_NTAPI_CC refresh_get_tick_count64(boost::winapi::PVOID_, boost::winapi::BOOLEAN_)
{
get_tick_count64();
}
@@ -88,7 +88,7 @@ void cleanup_get_tick_count64()
}
}
ticks_type WINAPI get_tick_count_init()
ticks_type BOOST_WINAPI_WINAPI_CC get_tick_count_init()
{
boost::winapi::HMODULE_ hKernel32 = boost::winapi::GetModuleHandleW(L"kernel32.dll");
if (hKernel32)

View File

@@ -13,8 +13,10 @@
#include <windows.h>
#if defined(__BORLANDC__)
#if defined(BOOST_BORLANDC)
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
#elif defined(BOOST_EMBTC)
extern "C" int _libmain(DWORD dwReason)
#elif defined(_WIN32_WCE)
extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/)
#else

View File

@@ -152,19 +152,25 @@ extern BOOL (WINAPI * const _pDefaultRawDllMainOrig)(HINSTANCE, DWORD, LPVOID) =
static PVAPI_V on_process_init();
static PVAPI_V on_process_term();
static void NTAPI on_tls_callback(HINSTANCE, DWORD, PVOID);
}
namespace boost
{
//The .CRT$Xxx information is taken from Codeguru:
//http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c6945__2/
// Variables below are not referenced anywhere and
// to not be optimized away has to have external linkage
#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"))_PIFV_ 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;
extern const __declspec(allocate(".CRT$XLC")) _TLSCB p_tls_callback = on_tls_callback;
extern const __declspec(allocate(".CRT$XIU")) _PIFV_ p_tls_prepare = on_tls_prepare;
extern const __declspec(allocate(".CRT$XCU")) _PVFV_ p_process_init = on_process_init;
extern const __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)
@@ -176,30 +182,33 @@ extern BOOL (WINAPI * const _pDefaultRawDllMainOrig)(HINSTANCE, DWORD, LPVOID) =
//this could be changed easily if required.
#pragma data_seg(".CRT$XIU")
static _PIFV_ p_tls_prepare = on_tls_prepare;
extern const _PIFV_ 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;
extern const _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;
extern const _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;
extern const _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
} // namespace boost
namespace
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4189)

View File

@@ -34,8 +34,7 @@ project
<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>-Wno-variadic-macros
#<toolset>gcc:<cxxflags>-Wunused-local-typedefs
<toolset>gcc:<cxxflags>-Wunused-function
<toolset>gcc:<cxxflags>-Wno-unused-parameter
@@ -62,6 +61,7 @@ project
#<toolset>clang:<cxxflags>-fpermissive # doesn't work
<toolset>clang:<cxxflags>-Wunused-function
<toolset>clang:<cxxflags>-Wno-unused-parameter
<toolset>clang:<cxxflags>-Wno-c99-extensions
#<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
@@ -368,6 +368,10 @@ rule generate_self_contained_header_tests
[ thread-run test_10964.cpp ]
[ thread-test test_11053.cpp ]
[ thread-run test_11266.cpp ]
[ thread-run test_366_1.cpp ]
[ thread-run test_366_2.cpp ]
[ thread-run test_366_3.cpp ]
[ thread-run test_366_4.cpp ]
;
@@ -1095,4 +1099,10 @@ rule generate_self_contained_header_tests
;
test-suite test_self_contained_headers : [ generate_self_contained_header_tests ] ;
test-suite detail
:
[ run detail/string_trim_test.cpp ]
[ run detail/string_to_unsigned_test.cpp ]
;
}

View File

@@ -0,0 +1,55 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/thread/detail/string_to_unsigned.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
using boost::thread_detail::string_to_unsigned;
unsigned v;
BOOST_TEST_NOT( string_to_unsigned( "", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST_NOT( string_to_unsigned( " ", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST_NOT( string_to_unsigned( "+1", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST_NOT( string_to_unsigned( "-1", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST_NOT( string_to_unsigned( "abc", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST( string_to_unsigned( "0", v ) ) && BOOST_TEST_EQ( v, 0 );
BOOST_TEST( string_to_unsigned( "1", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "12", v ) ) && BOOST_TEST_EQ( v, 12 );
BOOST_TEST( string_to_unsigned( "123", v ) ) && BOOST_TEST_EQ( v, 123 );
BOOST_TEST( string_to_unsigned( "1234", v ) ) && BOOST_TEST_EQ( v, 1234 );
BOOST_TEST( string_to_unsigned( "12345", v ) ) && BOOST_TEST_EQ( v, 12345 );
BOOST_TEST( string_to_unsigned( "123456", v ) ) && BOOST_TEST_EQ( v, 123456 );
BOOST_TEST( string_to_unsigned( "1234567", v ) ) && BOOST_TEST_EQ( v, 1234567 );
BOOST_TEST( string_to_unsigned( "12345678", v ) ) && BOOST_TEST_EQ( v, 12345678 );
BOOST_TEST( string_to_unsigned( "123456789", v ) ) && BOOST_TEST_EQ( v, 123456789 );
BOOST_TEST( string_to_unsigned( "1234567890", v ) ) && BOOST_TEST_EQ( v, 1234567890 );
BOOST_TEST_NOT( string_to_unsigned( "12345678901", v ) ) && BOOST_TEST_EQ( v, 1234567890 );
BOOST_TEST_NOT( string_to_unsigned( "123456789012", v ) ) && BOOST_TEST_EQ( v, 1234567890 );
BOOST_TEST( string_to_unsigned( "4294967295", v ) ) && BOOST_TEST_EQ( v, 4294967295 );
BOOST_TEST_NOT( string_to_unsigned( "4294967296", v ) ) && BOOST_TEST_EQ( v, 429496729 );
BOOST_TEST( string_to_unsigned( "01", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "0001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "00001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "0000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "00000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "0000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "00000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "000000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "0000000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST( string_to_unsigned( "00000000000001", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST_NOT( string_to_unsigned( "1a", v ) ) && BOOST_TEST_EQ( v, 1 );
BOOST_TEST_NOT( string_to_unsigned( "2 ", v ) ) && BOOST_TEST_EQ( v, 2 );
return boost::report_errors();
}

View File

@@ -0,0 +1,48 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/thread/detail/string_trim.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
using boost::thread_detail::string_trim;
BOOST_TEST_EQ( string_trim( "" ), std::string( "" ) );
BOOST_TEST_EQ( string_trim( " " ), std::string( "" ) );
BOOST_TEST_EQ( string_trim( " " ), std::string( "" ) );
BOOST_TEST_EQ( string_trim( " " ), std::string( "" ) );
BOOST_TEST_EQ( string_trim( " \t\r\n \t\r\n" ), std::string( "" ) );
BOOST_TEST_EQ( string_trim( "a" ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a" ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a" ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a" ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( "a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( "a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( "a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( " a " ), std::string( "a" ) );
BOOST_TEST_EQ( string_trim( "a b" ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b" ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b" ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b" ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( "a b " ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( "a b " ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( "a b " ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b " ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b " ), std::string( "a b" ) );
BOOST_TEST_EQ( string_trim( " a b " ), std::string( "a b" ) );
return boost::report_errors();
}

View File

@@ -26,8 +26,6 @@
#pragma warning(disable: 4127) // conditional expression is constant
#endif
namespace boost
{
template <typename T>
struct wrap
{
@@ -37,9 +35,8 @@ struct wrap
};
template <typename T>
exception_ptr make_exception_ptr(T v) {
return copy_exception(wrap<T>(v));
}
boost::exception_ptr make_exception_ptr(T v) {
return boost::copy_exception(wrap<T>(v));
}
void func1(boost::promise<int> p)
@@ -51,7 +48,7 @@ void func1(boost::promise<int> p)
void func2(boost::promise<int> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
}
int j = 0;
@@ -66,7 +63,7 @@ void func3(boost::promise<int&> p)
void func4(boost::promise<int&> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
}
void func5(boost::promise<void> p)
@@ -78,7 +75,7 @@ void func5(boost::promise<void> p)
void func6(boost::promise<void> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(4));
p.set_exception(::make_exception_ptr(4));
}
@@ -110,7 +107,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func2, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
#endif
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
try
@@ -159,7 +156,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func4, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
#endif
try
{

View File

@@ -36,8 +36,6 @@
#pragma warning(disable: 4127) // conditional expression is constant
#endif
namespace boost
{
template <typename T>
struct wrap
{
@@ -47,9 +45,8 @@ struct wrap
};
template <typename T>
exception_ptr make_exception_ptr(T v) {
return copy_exception(wrap<T>(v));
}
boost::exception_ptr make_exception_ptr(T v) {
return boost::copy_exception(wrap<T>(v));
}
void func1(boost::promise<int> p)
@@ -61,7 +58,7 @@ void func1(boost::promise<int> p)
void func2(boost::promise<int> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
}
int j = 0;
@@ -76,7 +73,7 @@ void func3(boost::promise<int&> p)
void func4(boost::promise<int&> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
}
void func5(boost::promise<void> p)
@@ -88,7 +85,7 @@ void func5(boost::promise<void> p)
void func6(boost::promise<void> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(4));
p.set_exception(::make_exception_ptr(4));
}
@@ -120,7 +117,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func2, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
#endif
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
try
@@ -133,7 +130,7 @@ int main()
BOOST_TEST(false);
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
}
catch (boost::wrap<int> const& i)
catch (::wrap<int> const& i)
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
BOOST_TEST(i.value == 3);
@@ -177,7 +174,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func4, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
#endif
try
{
@@ -185,7 +182,7 @@ int main()
BOOST_TEST(f.get() == 3);
BOOST_TEST(false);
}
catch (boost::wrap<double> const& i)
catch (::wrap<double> const& i)
{
BOOST_TEST(i.value == 3.5);
}
@@ -200,7 +197,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func4, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
#endif
try
{
@@ -238,7 +235,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func6, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(4));
p.set_exception(::make_exception_ptr(4));
#endif
try
{
@@ -246,7 +243,7 @@ int main()
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> const& i)
catch (::wrap<int> const& i)
{
BOOST_TEST(i.value == 4);
}

View File

@@ -48,22 +48,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

View File

@@ -46,22 +46,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

View File

@@ -49,22 +49,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

View File

@@ -24,8 +24,6 @@
#include <boost/detail/lightweight_test.hpp>
#include <boost/static_assert.hpp>
namespace boost
{
template <typename T>
struct wrap
{
@@ -38,11 +36,10 @@ namespace boost
};
template <typename T>
exception_ptr make_exception_ptr(T v)
boost::exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
return boost::copy_exception(wrap<T> (v));
}
}
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
void func(boost::promise<int> p)
@@ -51,8 +48,8 @@ boost::promise<int> p;
void func()
#endif
{
//p.set_exception(boost::make_exception_ptr(3));
p.set_exception_at_thread_exit(boost::make_exception_ptr(3));
//p.set_exception(::make_exception_ptr(3));
p.set_exception_at_thread_exit(::make_exception_ptr(3));
}
int main()
@@ -72,7 +69,7 @@ int main()
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> i)
catch (::wrap<int> i)
{
BOOST_TEST(i.value == 3);
}
@@ -96,7 +93,7 @@ int main()
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> i)
catch (::wrap<int> i)
{
BOOST_TEST(i.value == 3);
}

View File

@@ -24,8 +24,6 @@
#include <boost/detail/lightweight_test.hpp>
#include <boost/static_assert.hpp>
namespace boost
{
template <typename T>
struct wrap
{
@@ -38,11 +36,10 @@ namespace boost
};
template <typename T>
exception_ptr make_exception_ptr(T v)
boost::exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
return boost::copy_exception(wrap<T> (v));
}
}
int main()
{
@@ -51,19 +48,19 @@ int main()
typedef int T;
boost::promise<T> p;
boost::future<T> f = p.get_future();
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
try
{
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> i)
catch (::wrap<int> i)
{
BOOST_TEST(i.value == 3);
}
try
{
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
BOOST_TEST(false);
}
catch (const boost::future_error& e)
@@ -79,7 +76,7 @@ int main()
typedef int T;
boost::promise<T> p;
boost::future<T> f = p.get_future();
p.set_exception_deferred(boost::make_exception_ptr(3));
p.set_exception_deferred(::make_exception_ptr(3));
BOOST_TEST(!f.is_ready());
p.notify_deferred();
try
@@ -87,13 +84,13 @@ int main()
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> i)
catch (::wrap<int> i)
{
BOOST_TEST(i.value == 3);
}
try
{
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
BOOST_TEST(false);
}
catch (const boost::future_error& e)

View File

@@ -28,8 +28,6 @@
#if defined BOOST_THREAD_USES_CHRONO
namespace boost
{
template <typename T>
struct wrap
{
@@ -39,9 +37,8 @@ struct wrap
};
template <typename T>
exception_ptr make_exception_ptr(T v) {
return copy_exception(wrap<T>(v));
}
boost::exception_ptr make_exception_ptr(T v) {
return boost::copy_exception(wrap<T>(v));
}
void func1(boost::promise<int> p)
@@ -53,7 +50,7 @@ void func1(boost::promise<int> p)
void func2(boost::promise<int> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
}
int j = 0;
@@ -68,7 +65,7 @@ void func3(boost::promise<int&> p)
void func4(boost::promise<int&> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
}
void func5(boost::promise<void> p)
@@ -80,7 +77,7 @@ void func5(boost::promise<void> p)
void func6(boost::promise<void> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p.set_exception(boost::make_exception_ptr(4));
p.set_exception(::make_exception_ptr(4));
}
@@ -106,7 +103,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func2, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3));
p.set_exception(::make_exception_ptr(3));
#endif
try
{
@@ -114,7 +111,7 @@ int main()
BOOST_TEST(f.get() == 3);
BOOST_TEST(false);
}
catch (boost::wrap<int> const& i)
catch (::wrap<int> const& i)
{
BOOST_TEST(i.value == 3);
}
@@ -146,7 +143,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func4, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(3.5));
p.set_exception(::make_exception_ptr(3.5));
#endif
try
{
@@ -154,7 +151,7 @@ int main()
BOOST_TEST(f.get() == 3);
BOOST_TEST(false);
}
catch (boost::wrap<double> const& i)
catch (::wrap<double> const& i)
{
BOOST_TEST(i.value == 3.5);
}
@@ -181,7 +178,7 @@ int main()
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::thread(func6, boost::move(p)).detach();
#else
p.set_exception(boost::make_exception_ptr(4));
p.set_exception(::make_exception_ptr(4));
#endif
try
{
@@ -189,7 +186,7 @@ int main()
f.get();
BOOST_TEST(false);
}
catch (boost::wrap<int> const& i)
catch (::wrap<int> const& i)
{
BOOST_TEST(i.value == 4);
}

View File

@@ -48,22 +48,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

View File

@@ -46,22 +46,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

View File

@@ -49,22 +49,6 @@ namespace boost
os << underlying_cast<int>(st) << " ";
return os;
}
template <typename T>
struct wrap
{
wrap(T const& v) :
value(v)
{
}
T value;
};
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(wrap<T> (v));
}
}
void func1(boost::promise<int> p)

37
test/test_366_1.cpp Normal file
View File

@@ -0,0 +1,37 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include "boost/thread/thread_guard.hpp"
#include "boost/thread.hpp"
#include <boost/core/lightweight_test.hpp>
#include <iostream>
static void inner_thread_func()
{
boost::this_thread::sleep_for(
boost::chrono::hours(1) );
}
static void outer_thread_func()
{
boost::thread inner( inner_thread_func );
boost::thread_guard<boost::interrupt_and_join_if_joinable> guard( inner );
}
static void double_interrupt()
{
boost::thread outer( outer_thread_func );
boost::thread_guard<boost::interrupt_and_join_if_joinable> guard( outer );
}
int main()
{
BOOST_TEST( true ); // perform lwt initialization
std::cout << "Start" << std::endl;
double_interrupt();
std::cout << "End" << std::endl;
return boost::report_errors();
}

35
test/test_366_2.cpp Normal file
View File

@@ -0,0 +1,35 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include "boost/thread/scoped_thread.hpp"
#include "boost/thread.hpp"
#include <boost/core/lightweight_test.hpp>
#include <iostream>
static void inner_thread_func()
{
boost::this_thread::sleep_for(
boost::chrono::hours(1) );
}
static void outer_thread_func()
{
boost::scoped_thread<boost::interrupt_and_join_if_joinable> inner( inner_thread_func );
}
static void double_interrupt()
{
boost::scoped_thread<boost::interrupt_and_join_if_joinable> outer( outer_thread_func );
}
int main()
{
BOOST_TEST( true ); // perform lwt initialization
std::cout << "Start" << std::endl;
double_interrupt();
std::cout << "End" << std::endl;
return boost::report_errors();
}

35
test/test_366_3.cpp Normal file
View File

@@ -0,0 +1,35 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include "boost/thread/scoped_thread.hpp"
#include "boost/thread.hpp"
#include <boost/core/lightweight_test.hpp>
#include <iostream>
static void inner_thread_func()
{
boost::this_thread::sleep_for(
boost::chrono::hours(1) );
}
static void outer_thread_func()
{
boost::strict_scoped_thread<boost::interrupt_and_join_if_joinable> inner( inner_thread_func );
}
static void double_interrupt()
{
boost::strict_scoped_thread<boost::interrupt_and_join_if_joinable> outer( outer_thread_func );
}
int main()
{
BOOST_TEST( true ); // perform lwt initialization
std::cout << "Start" << std::endl;
double_interrupt();
std::cout << "End" << std::endl;
return boost::report_errors();
}

59
test/test_366_4.cpp Normal file
View File

@@ -0,0 +1,59 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include "boost/thread/scoped_thread.hpp"
#include "boost/thread.hpp"
#include <boost/core/lightweight_test.hpp>
#include <iostream>
static void do_first_half()
{
std::cout << "Doing first half of the work\n";
boost::this_thread::sleep_for(
boost::chrono::hours( 1 ) );
std::cout << "First half of the work complete\n";
}
static void do_second_half()
{
std::cout << "Doing second half of the work\n";
boost::this_thread::sleep_for(
boost::chrono::hours( 1 ) );
std::cout << "Second half of the work complete\n";
}
static void outer_thread_func()
{
boost::scoped_thread<boost::interrupt_and_join_if_joinable> worker1( do_first_half );
boost::scoped_thread<boost::interrupt_and_join_if_joinable> worker2( do_second_half );
worker1.join();
worker2.join();
}
int main()
{
BOOST_TEST( true ); // perform lwt initialization
std::cout << "Start" << std::endl;
{
boost::thread outer( outer_thread_func );
boost::this_thread::sleep_for( boost::chrono::seconds( 1 ) );
std::cout << "Interrupting work\n";
outer.interrupt();
outer.join();
}
std::cout << "End" << std::endl;
return boost::report_errors();
}

View File

@@ -14,7 +14,7 @@
#define BOOST_THREAD_TEST_TIME_MS 75
#else
// Windows, Cygwin, macOS all need this
#define BOOST_THREAD_TEST_TIME_MS 250
#define BOOST_THREAD_TEST_TIME_MS 400
#endif
#endif