mirror of
https://github.com/boostorg/thread.git
synced 2026-02-03 09:42:16 +00:00
Compare commits
37 Commits
boost-1.75
...
feature/ap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0264d6813 | ||
|
|
cf06d84362 | ||
|
|
ccc5e3142c | ||
|
|
97060416f1 | ||
|
|
88e32fd1ac | ||
|
|
5f41e68838 | ||
|
|
7d570f70d8 | ||
|
|
e62d29f917 | ||
|
|
09f01fbb05 | ||
|
|
fadb514c71 | ||
|
|
30dcb6dcbc | ||
|
|
27cb703930 | ||
|
|
d56f3f25ad | ||
|
|
52b62ee7b0 | ||
|
|
78af23ca14 | ||
|
|
743d19d7d3 | ||
|
|
7f7faf234d | ||
|
|
1de55fceda | ||
|
|
8db325363b | ||
|
|
f71e0f1645 | ||
|
|
7f36ea346f | ||
|
|
660f293809 | ||
|
|
d4b81d83f7 | ||
|
|
e4d16eb4d9 | ||
|
|
28a0a19cf0 | ||
|
|
fca97a8826 | ||
|
|
48e639b124 | ||
|
|
51f3e163b3 | ||
|
|
6fca28bfed | ||
|
|
636e4a869c | ||
|
|
f9d0e594d4 | ||
|
|
23e7658347 | ||
|
|
190ec21523 | ||
|
|
f17d23ac2a | ||
|
|
4abafccff4 | ||
|
|
c55e0952ee | ||
|
|
4bc126fc37 |
105
.github/workflows/ci.yml
vendored
Normal file
105
.github/workflows/ci.yml
vendored
Normal 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
|
||||
105
CMakeLists.txt
Normal file
105
CMakeLists.txt
Normal file
@@ -0,0 +1,105 @@
|
||||
# Generated by `boostdep --cmake thread`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
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::intrusive
|
||||
Boost::io
|
||||
Boost::iterator
|
||||
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
|
||||
|
||||
PRIVATE
|
||||
Boost::algorithm
|
||||
Boost::lexical_cast
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
15
appveyor.yml
15
appveyor.yml
@@ -18,9 +18,6 @@ image: Visual Studio 2015
|
||||
environment:
|
||||
matrix:
|
||||
|
||||
- TOOLSET: msvc-12.0
|
||||
VARIANT: release
|
||||
|
||||
- TOOLSET: msvc-14.0
|
||||
ADDRMD: 32
|
||||
VARIANT: debug
|
||||
@@ -45,20 +42,24 @@ environment:
|
||||
TOOLSET: gcc
|
||||
VARIANT: release
|
||||
|
||||
- ADDPATH: C:\mingw\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/
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83756
|
||||
#
|
||||
# - ADDPATH: C:\mingw\bin;
|
||||
# TOOLSET: gcc
|
||||
# CXXSTD: 11
|
||||
# VARIANT: debug
|
||||
#
|
||||
# - 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"std": [ "proposal" ],
|
||||
"category": [
|
||||
"Concurrent", "System"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ]
|
||||
;
|
||||
|
||||
|
||||
|
||||
37
test/test_366_1.cpp
Normal file
37
test/test_366_1.cpp
Normal 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
35
test/test_366_2.cpp
Normal 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
35
test/test_366_3.cpp
Normal 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
59
test/test_366_4.cpp
Normal 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();
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user