Compare commits

..

3 Commits

Author SHA1 Message Date
Christian Mazakas 085414479a Avoid shadowing wanrings from DateTime 2023-06-22 11:32:45 -07:00
Christian Mazakas 515412ce0a Fix header includes for boost::shared_lock 2023-06-22 11:32:34 -07:00
Christian Mazakas 6395ce0486 Add explicit tests for rw_spinlock 2023-06-22 09:44:54 -07:00
104 changed files with 649 additions and 545 deletions
+16 -30
View File
@@ -31,28 +31,14 @@ environment:
B2_VARIANT: debug,release
matrix:
- FLAVOR: Visual Studio 2008
- FLAVOR: Visual Studio 2008, 2010, 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-9.0
B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: Visual Studio 2010
- FLAVOR: Visual Studio 2013, 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-10.0
B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: Visual Studio 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-11.0
B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: Visual Studio 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-12.0
- FLAVOR: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-14.0
B2_TOOLSET: msvc-12.0,msvc-14.0
- FLAVOR: Visual Studio 2017, C++14
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
@@ -69,32 +55,32 @@ environment:
B2_CXXSTD: latest
B2_TOOLSET: msvc-14.1
- FLAVOR: cygwin (32-bit, C++03)
- FLAVOR: cygwin (32-bit, C++03,11)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 03
B2_CXXSTD: 03,11
B2_TOOLSET: gcc
- FLAVOR: cygwin (32-bit, C++11)
- FLAVOR: cygwin (32-bit, C++14,1z)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 11
B2_CXXSTD: 14,1z
B2_TOOLSET: gcc
- FLAVOR: cygwin (32-bit, C++14)
- FLAVOR: cygwin (64-bit, C++03,11)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 14
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 03,11
B2_TOOLSET: gcc
- FLAVOR: cygwin (32-bit, C++1z)
- FLAVOR: cygwin (64-bit, C++14,1z)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 1z
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 14,1z
B2_TOOLSET: gcc
- FLAVOR: cygwin (64-bit, latest, C++03)
+39 -57
View File
@@ -32,16 +32,6 @@ env:
CODECOV_NAME: Github Actions
jobs:
runner-selection:
# runs-on: ubuntu-latest
runs-on: ${{ github.repository_owner == 'boostorg' && fromJSON('[ "self-hosted", "linux", "x64", "ubuntu-latest-aws" ]') || 'ubuntu-latest' }}
outputs:
labelmatrix: ${{ steps.aws_hosted_runners.outputs.labelmatrix }}
steps:
- name: AWS Hosted Runners
id: aws_hosted_runners
uses: cppalliance/aws-hosted-runners@v1.0.0
posix:
defaults:
run:
@@ -52,55 +42,50 @@ jobs:
matrix:
include:
# Linux, gcc
- { compiler: gcc-7, cxxstd: '03,11,14,17', os: 'ubuntu-20.04', install: 'g++-7' }
- { compiler: gcc-8, cxxstd: '03,11,14,17', os: 'ubuntu-20.04', install: 'g++-8' }
- { compiler: gcc-9, cxxstd: '03,11,14,17', os: 'ubuntu-22.04', install: 'g++-9' }
- { compiler: gcc-10, cxxstd: '03,11,14,17,20', os: 'ubuntu-22.04', install: 'g++-10' }
- { compiler: gcc-11, cxxstd: '03,11,14,17,20', os: 'ubuntu-22.04', install: 'g++-11' }
- { compiler: gcc-7, cxxstd: '03,11,14,17', os: ubuntu-20.04, install: 'g++-7' }
- { compiler: gcc-8, cxxstd: '03,11,14,17', os: ubuntu-20.04, install: 'g++-8' }
- { compiler: gcc-9, cxxstd: '03,11,14,17', os: ubuntu-20.04, install: 'g++-9' }
- { compiler: gcc-10, cxxstd: '03,11,14,17,20', os: ubuntu-22.04, install: 'g++-10' }
- { compiler: gcc-11, cxxstd: '03,11,14,17,20', os: ubuntu-22.04, install: 'g++-11' }
- { name: "gcc-12 w/ sanitizers (03,11,14)", sanitize: yes,
compiler: gcc-12, cxxstd: '03,11,14', os: 'ubuntu-22.04', ccache_key: "san1" }
compiler: gcc-12, cxxstd: '03,11,14', os: ubuntu-22.04, ccache_key: "san1" }
- { name: "gcc-12 w/ sanitizers (17,20,2b)", sanitize: yes,
compiler: gcc-12, cxxstd: '17,20,2b', os: 'ubuntu-22.04', ccache_key: "san2" }
compiler: gcc-12, cxxstd: '17,20,2b', os: ubuntu-22.04, ccache_key: "san2" }
- { name: Collect coverage, coverage: yes,
compiler: gcc-12, cxxstd: '03,20', os: 'ubuntu-22.04', install: 'g++-12-multilib', address-model: '32,64', ccache_key: "cov" }
compiler: gcc-12, cxxstd: '03,20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '32,64', ccache_key: "cov" }
- { name: "cfoa tsan (gcc-12)", cxxstd: '11,14,17,20,2b', os: 'ubuntu-22.04', compiler: gcc-12,
targets: 'libs/unordered/test//cfoa_tests', thread-sanitize: yes, ccache_key: "tsan" }
- { name: "cfoa tsan (gcc)", cxxstd: '11,14,17,20,2b', os: ubuntu-22.04, compiler: gcc-12,
targets: 'libs/unordered/test//cfoa_tests', thread-sanitize: yes }
# Linux, clang, libc++
- { compiler: clang-7, cxxstd: '03,11,14,17', os: 'ubuntu-20.04', stdlib: libc++, install: 'clang-7 libc++-7-dev libc++abi-7-dev' }
- { compiler: clang-10, cxxstd: '03,11,14,17,20', os: 'ubuntu-20.04', stdlib: libc++, install: 'clang-10 libc++-10-dev libc++abi-10-dev' }
- { compiler: clang-11, cxxstd: '03,11,14,17,20', os: 'ubuntu-22.04', stdlib: libc++, install: 'clang-11 libc++-11-dev libc++abi-11-dev' }
# clang-12 doesn't work on 'ubuntu-22.04', the linker can't find -lunwind for some reason
- { compiler: clang-7, cxxstd: '03,11,14,17', os: ubuntu-20.04, stdlib: libc++, install: 'clang-7 libc++-7-dev libc++abi-7-dev' }
- { compiler: clang-10, cxxstd: '03,11,14,17,20', os: ubuntu-20.04, stdlib: libc++, install: 'clang-10 libc++-10-dev libc++abi-10-dev' }
- { compiler: clang-11, cxxstd: '03,11,14,17,20', os: ubuntu-22.04, stdlib: libc++, install: 'clang-11 libc++-11-dev libc++abi-11-dev' }
# clang-12 doesn't work on ubuntu-22.04, the linker can't find -lunwind for some reason
- { name: "clang-12 w/ sanitizers (03,11,14)", sanitize: yes,
compiler: clang-12, cxxstd: '03,11,14', os: 'ubuntu-20.04', stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', ccache_key: "san1" }
compiler: clang-12, cxxstd: '03,11,14', os: ubuntu-20.04, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', ccache_key: "san1" }
- { name: "clang-12 w/ sanitizers (17,20,2b)", sanitize: yes,
compiler: clang-12, cxxstd: '17,20,2b', os: 'ubuntu-20.04', stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', ccache_key: "san2" }
- { compiler: clang-13, cxxstd: '03,11,14,17,20,2b', os: 'ubuntu-22.04', stdlib: libc++, install: 'clang-13 libc++-13-dev libc++abi-13-dev' }
compiler: clang-12, cxxstd: '17,20,2b', os: ubuntu-20.04, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', ccache_key: "san2" }
- { compiler: clang-13, cxxstd: '03,11,14,17,20,2b', os: ubuntu-22.04, stdlib: libc++, install: 'clang-13 libc++-13-dev libc++abi-13-dev' }
- { compiler: clang-14, cxxstd: '03,11,14,17,20,2b', os: ubuntu-22.04, stdlib: libc++, install: 'clang-14 libc++-14-dev libc++abi-14-dev' }
# not using libc++ because of https://github.com/llvm/llvm-project/issues/52771
- { name: "clang-14 w/ sanitizers (03,11,14)", sanitize: yes,
compiler: clang-14, cxxstd: '03,11,14', os: 'ubuntu-22.04', ccache_key: "san1" }
compiler: clang-14, cxxstd: '03,11,14', os: ubuntu-22.04, ccache_key: "san1" }
- { name: "clang-14 w/ sanitizers (17,20,2b)", sanitize: yes,
compiler: clang-14, cxxstd: '17,20,2b', os: 'ubuntu-22.04', ccache_key: "san2" }
compiler: clang-14, cxxstd: '17,20,2b', os: ubuntu-22.04, ccache_key: "san2" }
- { name: "cfoa tsan (clang-14)", cxxstd: '11,14,17,20,2b', os: 'ubuntu-22.04', compiler: clang-14,
- { name: "cfoa tsan (clang)", cxxstd: '11,14,17,20,2b', os: ubuntu-22.04, compiler: clang-14,
targets: 'libs/unordered/test//cfoa_tests', thread-sanitize: yes,
stdlib: libc++, install: 'clang-14 libc++-14-dev libc++abi-14-dev', ccache_key: "tsan" }
- { compiler: clang-15, cxxstd: '03,11,14,17,20,2b', os: 'ubuntu-22.04', stdlib: libc++, install: 'clang-15 libc++-15-dev libc++abi-15-dev' }
stdlib: libc++, install: 'clang-14 libc++-14-dev libc++abi-14-dev' }
# OSX, clang
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: 'macos-11' }
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: 'macos-12', sanitize: yes, ccache_key: "san1" }
- { compiler: clang, cxxstd: '11,14,17,2a', os: 'macos-12', thread-sanitize: yes, targets: 'libs/unordered/test//cfoa_tests', ccache_key: "tsan" }
- { compiler: clang, cxxstd: '03,11,14,17,20,2b', os: 'macos-13' }
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: macos-11, }
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: macos-12, sanitize: yes }
- { compiler: clang, cxxstd: '11,14,17,2a', os: macos-12, thread-sanitize: yes, targets: 'libs/unordered/test//cfoa_tests' }
timeout-minutes: 360
# posix (gcc-12 w/ sanitizers is taking longer than 210 minutes
# timeout-minutes: 210
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
timeout-minutes: 180
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
env: {B2_USE_CCACHE: 1}
@@ -244,16 +229,15 @@ jobs:
fail-fast: false
matrix:
include:
- { toolset: msvc-14.0, cxxstd: '14,latest', addrmd: '32,64', os: 'windows-2019', variant: 'debug,release' }
- { toolset: msvc-14.2, cxxstd: '14,17,20,latest', addrmd: '32,64', os: 'windows-2019', variant: 'debug,release' }
- { toolset: msvc-14.3, cxxstd: '14,17,20,latest', addrmd: '32,64', os: 'windows-2022', variant: 'debug,release' }
- { toolset: msvc-14.3, cxxstd: '14', addrmd: '64', os: 'windows-2022', variant: 'debug', defines: '_ALLOW_RTCc_IN_STL', cxxflags: '/RTCc' }
- { toolset: msvc-14.3, cxxstd: '14', addrmd: '32', os: 'windows-2022', variant: 'debug', defines: '_ALLOW_RTCc_IN_STL', cxxflags: '"/RTCc /arch:IA32"' }
- { toolset: clang-win, cxxstd: '14,17,latest', addrmd: '32,64', os: 'windows-2022', variant: 'debug,release' }
- { toolset: gcc, cxxstd: '03,11,14,17,2a', addrmd: '64', os: 'windows-2019', variant: 'debug,release' }
- { toolset: msvc-14.0, cxxstd: '14,latest', addrmd: '32,64', os: windows-2019, variant: 'debug,release' }
- { toolset: msvc-14.2, cxxstd: '14,17,20,latest', addrmd: '32,64', os: windows-2019, variant: 'debug,release' }
- { toolset: msvc-14.3, cxxstd: '14,17,20,latest', addrmd: '32,64', os: windows-2022, variant: 'debug,release' }
- { toolset: msvc-14.3, cxxstd: '14', addrmd: '64', os: windows-2022, variant: 'debug', defines: '_ALLOW_RTCc_IN_STL', cxxflags: '/RTCc' }
- { toolset: msvc-14.3, cxxstd: '14', addrmd: '32', os: windows-2022, variant: 'debug', defines: '_ALLOW_RTCc_IN_STL', cxxflags: '"/RTCc /arch:IA32"' }
- { toolset: clang-win, cxxstd: '14,17,latest', addrmd: '32,64', os: windows-2022, variant: 'debug,release' }
- { toolset: gcc, cxxstd: '03,11,14,17,2a', addrmd: '64', os: windows-2019, variant: 'debug,release' }
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
@@ -310,8 +294,7 @@ jobs:
- { sys: MINGW32, compiler: gcc, cxxstd: '03,11,17,20' }
- { sys: MINGW64, compiler: gcc, cxxstd: '03,11,17,20' }
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)['windows-latest'] }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
@@ -365,12 +348,11 @@ jobs:
fail-fast: false
matrix:
include:
- { os: 'ubuntu-20.04', build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
- { os: 'windows-2019', build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' }
- { os: ubuntu-20.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
- { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' }
timeout-minutes: 120
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 51 KiB

+6 -6
View File
@@ -298,7 +298,7 @@ The successful lookup benchmarks are done by looking up all `n` values, in their
The unsuccessful lookup benchmarks use `n` randomly generated integers but using a different seed value.
=== GCC 12, x64
=== GCC 11, x64
[caption=]
@@ -317,7 +317,7 @@ h|unsuccessful lookup
|===
=== Clang 15, x64
=== Clang 12, x64
[caption=]
@@ -336,7 +336,7 @@ h|unsuccessful lookup
|===
=== Visual Studio 2022, x64
=== Visual Studio 2019, x64
[caption=]
@@ -374,7 +374,7 @@ h|unsuccessful lookup
|===
=== GCC 12, x86
=== GCC 11, x86
[caption=]
@@ -393,7 +393,7 @@ h|unsuccessful lookup
|===
=== Clang 15, x86
=== Clang 12, x86
[caption=]
@@ -412,7 +412,7 @@ h|unsuccessful lookup
|===
=== Visual Studio 2022, x86
=== Visual Studio 2019, x86
[caption=]
@@ -662,7 +662,7 @@ namespace boost {
float max_load_factor() const noexcept
{
return table_.max_load_factor();
}
};
void max_load_factor(float) {}
size_type max_load() const noexcept { return table_.max_load(); }
+1 -1
View File
@@ -285,7 +285,7 @@ struct group15
std::size_t pos=reinterpret_cast<uintptr_t>(pc)%sizeof(group15);
group15 *pg=reinterpret_cast<group15*>(pc-pos);
return !pg->is_not_overflowed(*pc);
}
};
inline int match_available()const
{
@@ -6,7 +6,6 @@
#define BOOST_UNORDERED_DETAIL_FOA_NODE_MAP_TYPES_HPP
#include <boost/core/allocator_access.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/core/pointer_traits.hpp>
namespace boost {
@@ -6,7 +6,6 @@
#define BOOST_UNORDERED_DETAIL_FOA_NODE_SET_TYPES_HPP
#include <boost/core/allocator_access.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/core/pointer_traits.hpp>
namespace boost {
@@ -1624,7 +1624,7 @@ namespace boost {
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
iterator() : p(), itb(){}
iterator() : p(), itb(){};
reference operator*() const BOOST_NOEXCEPT { return dereference(); }
pointer operator->() const BOOST_NOEXCEPT
@@ -1715,7 +1715,7 @@ namespace boost {
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
c_iterator() : p(), itb(){}
c_iterator() : p(), itb(){};
c_iterator(iterator<Node, Bucket> it) : p(it.p), itb(it.itb) {}
reference operator*() const BOOST_NOEXCEPT { return dereference(); }
@@ -3393,7 +3393,7 @@ namespace boost {
}
}
buckets_.unlink_empty_buckets();
BOOST_RETHROW
BOOST_RETHROW;
}
BOOST_CATCH_END
+3 -9
View File
@@ -20,7 +20,7 @@ function(foa_tests)
endfunction()
function(cfoa_tests)
boost_test(PREFIX boost_unordered_cfoa LINK_LIBRARIES Boost::compat Threads::Threads ${ARGN})
boost_test(PREFIX boost_unordered_cfoa LINK_LIBRARIES Threads::Threads ${ARGN})
endfunction()
# FCA tests
@@ -140,6 +140,8 @@ foa_tests(SOURCES exception/merge_exception_tests.cpp)
# CFOA tests
cfoa_tests(SOURCES cfoa/rw_spinlock_tests.cpp)
cfoa_tests(SOURCES cfoa/latch_tests.cpp)
cfoa_tests(SOURCES cfoa/insert_tests.cpp)
cfoa_tests(SOURCES cfoa/erase_tests.cpp)
cfoa_tests(SOURCES cfoa/try_emplace_tests.cpp)
@@ -158,13 +160,5 @@ cfoa_tests(SOURCES cfoa/exception_erase_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_constructor_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_assign_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_merge_tests.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test2.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test3.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test4.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test5.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test6.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test7.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test8.cpp)
endif()
+2 -8
View File
@@ -176,6 +176,8 @@ alias foa_tests :
;
local CFOA_TESTS =
latch_tests
rw_spinlock_tests
insert_tests
erase_tests
try_emplace_tests
@@ -194,14 +196,6 @@ local CFOA_TESTS =
exception_constructor_tests
exception_assign_tests
exception_merge_tests
rw_spinlock_test
rw_spinlock_test2
rw_spinlock_test3
rw_spinlock_test4
rw_spinlock_test5
rw_spinlock_test6
rw_spinlock_test7
rw_spinlock_test8
;
for local test in $(CFOA_TESTS)
+1 -1
View File
@@ -787,7 +787,7 @@ namespace {
std::thread t1, t2, t3;
boost::compat::latch start_latch(2), end_latch(2);
boost::latch start_latch(2), end_latch(2);
auto v1 = make_random_values(1024 * 16, [&] { return gen(rg); });
auto v2 = v1;
+3 -2
View File
@@ -2,10 +2,11 @@
// 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 "latch.hpp"
#include "../helpers/generators.hpp"
#include "../helpers/test.hpp"
#include <boost/compat/latch.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/core/span.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
@@ -369,7 +370,7 @@ std::vector<boost::span<T> > split(
template <class T, class F> void thread_runner(std::vector<T>& values, F f)
{
boost::compat::latch latch(static_cast<std::ptrdiff_t>(num_threads));
boost::latch latch(static_cast<std::ptrdiff_t>(num_threads));
std::vector<std::thread> threads;
auto subslices = split<T>(values, num_threads);
+3 -2
View File
@@ -5,10 +5,11 @@
#ifndef BOOST_UNORDERED_TEST_CFOA_HELPERS_HPP
#define BOOST_UNORDERED_TEST_CFOA_HELPERS_HPP
#include "latch.hpp"
#include "../helpers/generators.hpp"
#include "../helpers/test.hpp"
#include <boost/compat/latch.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/core/span.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
@@ -338,7 +339,7 @@ std::vector<boost::span<T> > split(
template <class T, class F> void thread_runner(std::vector<T>& values, F f)
{
boost::compat::latch latch(static_cast<std::ptrdiff_t>(num_threads));
boost::latch latch(static_cast<std::ptrdiff_t>(num_threads));
std::vector<std::thread> threads;
auto subslices = split<T>(values, num_threads);
+87
View File
@@ -0,0 +1,87 @@
// Copyright (C) 2023 Christian Mazakas
// 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)
#ifndef BOOST_UNORDERED_TEST_CFOA_LATCH_HPP
#define BOOST_UNORDERED_TEST_CFOA_LATCH_HPP
#include <boost/assert.hpp>
#include <climits>
#include <condition_variable>
#include <cstddef>
#include <mutex>
namespace boost {
class latch
{
private:
std::ptrdiff_t n_;
mutable std::mutex m_;
mutable std::condition_variable cv_;
public:
explicit latch(std::ptrdiff_t expected) : n_{expected}, m_{}, cv_{}
{
BOOST_ASSERT(n_ >= 0);
BOOST_ASSERT(n_ <= max());
}
latch(latch const&) = delete;
latch& operator=(latch const&) = delete;
~latch() = default;
void count_down(std::ptrdiff_t n = 1)
{
std::unique_lock<std::mutex> lk(m_);
count_down_and_notify(lk, n);
}
bool try_wait() const noexcept
{
std::unique_lock<std::mutex> lk(m_);
return is_ready();
}
void wait() const
{
std::unique_lock<std::mutex> lk(m_);
wait_impl(lk);
}
void arrive_and_wait(std::ptrdiff_t n = 1)
{
std::unique_lock<std::mutex> lk(m_);
bool should_wait = count_down_and_notify(lk, n);
if (should_wait) {
wait_impl(lk);
}
}
static constexpr std::ptrdiff_t max() noexcept { return INT_MAX; }
private:
bool is_ready() const { return n_ == 0; }
bool count_down_and_notify(
std::unique_lock<std::mutex>& lk, std::ptrdiff_t n)
{
n_ -= n;
if (n_ == 0) {
lk.unlock();
cv_.notify_all();
return false;
}
return true;
}
void wait_impl(std::unique_lock<std::mutex>& lk) const
{
cv_.wait(lk, [this] { return this->is_ready(); });
}
};
} // namespace boost
#endif // BOOST_UNORDERED_TEST_CFOA_LATCH_HPP
+155
View File
@@ -0,0 +1,155 @@
// Copyright (C) 2023 Christian Mazakas
// 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 BOOST_ENABLE_ASSERT_HANDLER
#include "latch.hpp"
#include <boost/core/lightweight_test.hpp>
#include <thread>
#include <vector>
struct exception
{
};
namespace boost {
void assertion_failed(
char const* expr, char const* function, char const* file, long line)
{
(void)expr;
(void)function;
(void)file;
(void)line;
throw exception{};
}
} // namespace boost
namespace {
void test_max() { BOOST_TEST_EQ(boost::latch::max(), INT_MAX); }
void test_constructor()
{
{
auto const f = [] {
boost::latch l(-1);
(void)l;
};
BOOST_TEST_THROWS(f(), exception);
}
{
std::ptrdiff_t n = 0;
boost::latch l(n);
BOOST_TEST(l.try_wait());
}
{
std::ptrdiff_t n = 16;
boost::latch l(n);
BOOST_TEST_NOT(l.try_wait());
l.count_down(16);
BOOST_TEST(l.try_wait());
}
#if PTRDIFF_MAX > INT_MAX
{
auto const f = [] {
std::ptrdiff_t n = INT_MAX;
n += 10;
boost::latch l(n);
(void)l;
};
BOOST_TEST_THROWS(f(), exception);
}
#endif
}
void test_count_down_and_wait()
{
constexpr std::ptrdiff_t n = 1024;
boost::latch l(2 * n);
bool bs[] = {false, false};
std::thread t1([&] {
l.wait();
BOOST_TEST(bs[0]);
BOOST_TEST(bs[1]);
});
std::thread t2([&] {
for (int i = 0; i < n; ++i) {
if (i == (n - 1)) {
bs[0] = true;
} else {
BOOST_TEST_NOT(l.try_wait());
}
l.count_down(1);
}
});
for (int i = 0; i < n; ++i) {
if (i == (n - 1)) {
bs[1] = true;
} else {
BOOST_TEST_NOT(l.try_wait());
}
l.count_down(1);
}
t1.join();
t2.join();
BOOST_TEST(l.try_wait());
}
void test_arrive_and_wait()
{
std::ptrdiff_t const n = 16;
boost::latch l(2 * n);
int xs[n] = {0};
std::vector<std::thread> threads;
for (int i = 0; i < n; ++i) {
threads.emplace_back([&l, &xs, i, n] {
(void)n;
for (int j = 0; j < n; ++j) {
BOOST_TEST_EQ(xs[j], 0);
}
l.arrive_and_wait(2);
xs[i] = 1;
});
}
for (auto& t : threads) {
t.join();
}
for (int i = 0; i < n; ++i) {
BOOST_TEST_EQ(xs[i], 1);
}
}
} // namespace
int main()
{
test_max();
test_constructor();
test_count_down_and_wait();
test_arrive_and_wait();
return boost::report_errors();
}
+1 -1
View File
@@ -103,7 +103,7 @@ namespace {
map2_type x2(2 * vals1.size(), allocator_type(3));
std::thread t1, t2, t3;
boost::compat::latch l(2);
boost::latch l(2);
std::mutex m;
std::condition_variable cv;
+1 -1
View File
@@ -79,7 +79,7 @@ namespace {
map_type x(0, hasher(1), key_equal(2), allocator_type(3));
std::thread t1, t2, t3;
boost::compat::latch l(2);
boost::latch l(2);
std::mutex m;
std::condition_variable cv;
-26
View File
@@ -1,26 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <mutex>
using boost::unordered::detail::foa::rw_spinlock;
// Sanity check only
static rw_spinlock sp;
static rw_spinlock sp2;
int main()
{
sp.lock();
sp2.lock();
sp.unlock();
sp2.unlock();
{
std::lock_guard<rw_spinlock> lock( sp );
std::lock_guard<rw_spinlock> lock2( sp2 );
}
}
-41
View File
@@ -1,41 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
using boost::unordered::detail::foa::rw_spinlock;
static rw_spinlock sp;
static rw_spinlock sp2;
int main()
{
BOOST_TEST( sp.try_lock() );
BOOST_TEST( !sp.try_lock() );
BOOST_TEST( sp2.try_lock() );
BOOST_TEST( !sp.try_lock() );
BOOST_TEST( !sp2.try_lock() );
sp.unlock();
sp2.unlock();
sp.lock();
BOOST_TEST( !sp.try_lock() );
sp2.lock();
BOOST_TEST( !sp.try_lock() );
BOOST_TEST( !sp2.try_lock() );
sp.unlock();
sp2.unlock();
{
std::lock_guard<rw_spinlock> lock( sp );
BOOST_TEST( !sp.try_lock() );
std::lock_guard<rw_spinlock> lock2( sp2 );
BOOST_TEST( !sp.try_lock() );
BOOST_TEST( !sp2.try_lock() );
}
return boost::report_errors();
}
-49
View File
@@ -1,49 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
#include <thread>
#include <cstdio>
using boost::unordered::detail::foa::rw_spinlock;
static int count = 0;
static rw_spinlock sp;
void f( int k, int n )
{
std::printf( "Thread %d started.\n", k );
for( int i = 0; i < n; ++i )
{
std::lock_guard<rw_spinlock> lock( sp );
++count;
}
std::printf( "Thread %d finished.\n", k );
}
int main()
{
int const N = 1000000; // iterations
int const M = 8; // threads
std::thread th[ M ];
for( int i = 0; i < M; ++i )
{
th[ i ] = std::thread( f, i, N );
}
for( int i = 0; i < M; ++i )
{
th[ i ].join();
}
BOOST_TEST_EQ( count, N * M );
return boost::report_errors();
}
-29
View File
@@ -1,29 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/compat/shared_lock.hpp>
#include <mutex>
using boost::unordered::detail::foa::rw_spinlock;
static rw_spinlock sp;
static rw_spinlock sp2;
int main()
{
sp.lock();
sp2.lock_shared();
sp2.lock_shared();
sp.unlock();
sp2.unlock_shared();
sp2.unlock_shared();
{
std::lock_guard<rw_spinlock> lock( sp );
boost::compat::shared_lock<rw_spinlock> lock2( sp2 );
boost::compat::shared_lock<rw_spinlock> lock3( sp2 );
}
}
-42
View File
@@ -1,42 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/compat/shared_lock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
using boost::unordered::detail::foa::rw_spinlock;
static rw_spinlock sp;
int main()
{
{
BOOST_TEST( sp.try_lock_shared() );
BOOST_TEST( sp.try_lock_shared() );
sp.unlock_shared();
sp.unlock_shared();
}
{
BOOST_TEST( sp.try_lock() );
BOOST_TEST( !sp.try_lock_shared() );
sp.unlock();
}
{
std::lock_guard<rw_spinlock> lock( sp );
BOOST_TEST( !sp.try_lock_shared() );
}
{
boost::compat::shared_lock<rw_spinlock> lock( sp );
BOOST_TEST( !sp.try_lock() );
BOOST_TEST( sp.try_lock_shared() );
sp.unlock_shared();
}
return boost::report_errors();
}
-60
View File
@@ -1,60 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/compat/shared_lock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
#include <thread>
#include <cstdio>
using boost::unordered::detail::foa::rw_spinlock;
static int count = 0;
static rw_spinlock sp;
void f( int k, int n )
{
std::printf( "Thread %d started.\n", k );
int i = 0;
for( ;; ++i )
{
{
boost::compat::shared_lock<rw_spinlock> lock( sp );
if( count >= n ) break;
}
{
std::lock_guard<rw_spinlock> lock( sp );
if( count >= n ) break;
++count;
}
}
std::printf( "Thread %d finished (%i iterations).\n", k, i );
}
int main()
{
int const N = 1000000; // total iterations
int const M = 8; // threads
std::thread th[ M ];
for( int i = 0; i < M; ++i )
{
th[ i ] = std::thread( f, i, N );
}
for( int i = 0; i < M; ++i )
{
th[ i ].join();
}
BOOST_TEST_EQ( count, N );
return boost::report_errors();
}
-62
View File
@@ -1,62 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/compat/shared_lock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
#include <thread>
#include <cstdio>
using boost::unordered::detail::foa::rw_spinlock;
static int count = 0;
static rw_spinlock sp;
void f( int k, int n )
{
std::printf( "Thread %d started.\n", k );
int i = 0;
for( ;; ++i )
{
int oldc;
{
boost::compat::shared_lock<rw_spinlock> lock( sp );
if( count >= n ) break;
oldc = count;
}
{
std::lock_guard<rw_spinlock> lock( sp );
if( count == oldc ) ++count;
}
}
std::printf( "Thread %d finished (%i iterations).\n", k, i );
}
int main()
{
int const N = 1000000; // total iterations
int const M = 8; // threads
std::thread th[ M ];
for( int i = 0; i < M; ++i )
{
th[ i ] = std::thread( f, i, N );
}
for( int i = 0; i < M; ++i )
{
th[ i ].join();
}
BOOST_TEST_EQ( count, N );
return boost::report_errors();
}
-64
View File
@@ -1,64 +0,0 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#include <boost/compat/shared_lock.hpp>
#include <boost/core/lightweight_test.hpp>
#include <mutex>
#include <thread>
#include <cstdio>
using boost::unordered::detail::foa::rw_spinlock;
static int count = 0;
static rw_spinlock sp;
void f( int k, int m, int n )
{
std::printf( "Thread %d of %d started.\n", k, m );
for( int i = 0; i < n; ++i )
{
int oldc;
for( ;; )
{
{
boost::compat::shared_lock<rw_spinlock> lock( sp );
oldc = count;
}
if( oldc % m == k ) break;
}
{
std::lock_guard<rw_spinlock> lock( sp );
if( count == oldc ) ++count;
}
}
std::printf( "Thread %d of %d finished.\n", k, m );
}
int main()
{
int const N = 100; // total iterations
int const M = 4; // threads
std::thread th[ M ];
for( int i = 0; i < M; ++i )
{
th[ i ] = std::thread( f, i, M, N );
}
for( int i = 0; i < M; ++i )
{
th[ i ].join();
}
BOOST_TEST_EQ( count, N * M );
return boost::report_errors();
}
+279
View File
@@ -0,0 +1,279 @@
// Copyright 2023 Peter Dimov
// Copyright 2023 Christian Mazakas
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include "helpers.hpp"
#include <boost/unordered/detail/foa/rw_spinlock.hpp>
#ifdef BOOST_GCC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#ifdef BOOST_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#endif
#include <boost/thread/locks.hpp>
#include <boost/thread/lock_types.hpp>
#ifdef BOOST_GCC
#pragma GCC diagnostic pop
#endif
#ifdef BOOST_CLANG
#pragma GCC diagnostic pop
#endif
#include <mutex>
#include <shared_mutex>
#include <thread>
using boost::unordered::detail::foa::rw_spinlock;
static int lcount = 0;
UNORDERED_AUTO_TEST (rw_spinlock_test) {
rw_spinlock sp, sp2;
sp.lock();
sp2.lock();
sp.unlock();
sp2.unlock();
{
std::lock_guard<rw_spinlock> lock(sp);
std::lock_guard<rw_spinlock> lock2(sp2);
}
}
UNORDERED_AUTO_TEST (rw_spinlock_test2) {
rw_spinlock sp, sp2;
BOOST_TEST(sp.try_lock());
BOOST_TEST(!sp.try_lock());
BOOST_TEST(sp2.try_lock());
BOOST_TEST(!sp.try_lock());
BOOST_TEST(!sp2.try_lock());
sp.unlock();
sp2.unlock();
sp.lock();
BOOST_TEST(!sp.try_lock());
sp2.lock();
BOOST_TEST(!sp.try_lock());
BOOST_TEST(!sp2.try_lock());
sp.unlock();
sp2.unlock();
{
std::lock_guard<rw_spinlock> lock(sp);
BOOST_TEST(!sp.try_lock());
std::lock_guard<rw_spinlock> lock2(sp2);
BOOST_TEST(!sp.try_lock());
BOOST_TEST(!sp2.try_lock());
}
}
void f(rw_spinlock& sp, int n)
{
for (int i = 0; i < n; ++i) {
std::lock_guard<rw_spinlock> lock(sp);
++lcount;
}
}
UNORDERED_AUTO_TEST (rw_spinlock_test3) {
lcount = 0;
rw_spinlock sp;
int const N = 1000000; // iterations
int const M = 8; // threads
std::thread th[M];
for (int i = 0; i < M; ++i) {
th[i] = std::thread([=, &sp] { f(sp, N); });
}
for (int i = 0; i < M; ++i) {
th[i].join();
}
BOOST_TEST_EQ(lcount, N * M);
}
UNORDERED_AUTO_TEST (rw_spinlock_test4) {
rw_spinlock sp, sp2;
sp.lock();
sp2.lock_shared();
sp2.lock_shared();
sp.unlock();
sp2.unlock_shared();
sp2.unlock_shared();
{
std::lock_guard<rw_spinlock> lock(sp);
boost::shared_lock<rw_spinlock> lock2(sp2);
boost::shared_lock<rw_spinlock> lock3(sp2);
}
}
UNORDERED_AUTO_TEST (rw_spinlock_test5) {
rw_spinlock sp;
{
BOOST_TEST(sp.try_lock_shared());
BOOST_TEST(sp.try_lock_shared());
sp.unlock_shared();
sp.unlock_shared();
}
{
BOOST_TEST(sp.try_lock());
BOOST_TEST(!sp.try_lock_shared());
sp.unlock();
}
{
std::lock_guard<rw_spinlock> lock(sp);
BOOST_TEST(!sp.try_lock_shared());
}
{
boost::shared_lock<rw_spinlock> lock(sp);
BOOST_TEST(!sp.try_lock());
BOOST_TEST(sp.try_lock_shared());
sp.unlock_shared();
}
}
UNORDERED_AUTO_TEST (rw_spinlock_test6) {
lcount = 0;
rw_spinlock sp;
int const N = 1000000; // total iterations
int const M = 8; // threads
std::thread th[M];
for (int i = 0; i < M; ++i) {
int n = N;
th[i] = std::thread([n, &sp] {
for (;;) {
{
boost::shared_lock<rw_spinlock> lock(sp);
if (lcount >= n)
break;
}
{
std::lock_guard<rw_spinlock> lock(sp);
if (lcount >= n)
break;
++lcount;
}
}
});
}
for (int i = 0; i < M; ++i) {
th[i].join();
}
BOOST_TEST_EQ(lcount, N);
}
UNORDERED_AUTO_TEST (rw_spinlock_test7) {
rw_spinlock sp;
int const N = 1000000; // total iterations
int const M = 8; // threads
std::thread th[M];
for (int i = 0; i < M; ++i) {
int n = N;
th[i] = std::thread([=, &sp] {
for (;;) {
int oldc;
{
boost::shared_lock<rw_spinlock> lock(sp);
if (lcount >= n)
break;
oldc = lcount;
}
{
std::lock_guard<rw_spinlock> lock(sp);
if (lcount == oldc)
++lcount;
}
}
});
}
for (int i = 0; i < M; ++i) {
th[i].join();
}
BOOST_TEST_EQ(lcount, N);
}
UNORDERED_AUTO_TEST (rw_spinlock_test8) {
lcount = 0;
rw_spinlock sp;
int const N = 1000; // total iterations
int const M = 4; // threads
std::thread th[M];
for (int i = 0; i < M; ++i) {
int k = i;
int m = M;
int n = N;
th[i] = std::thread([k, m, n, &sp] {
for (int j = 0; j < n; ++j) {
int oldc;
for (;;) {
{
boost::shared_lock<rw_spinlock> lock(sp);
oldc = lcount;
}
if (oldc % m == k)
break;
}
{
std::lock_guard<rw_spinlock> lock(sp);
if (lcount == oldc)
++lcount;
}
}
});
}
for (int i = 0; i < M; ++i) {
th[i].join();
}
BOOST_TEST_EQ(lcount, N * M);
}
RUN_TESTS()
+1 -1
View File
@@ -190,7 +190,7 @@ namespace {
map_type x2(vals2.size(), hasher(2), key_equal(1), allocator_type(3));
std::thread t1, t2, t3;
boost::compat::latch l(2);
boost::latch l(2);
std::mutex m;
std::condition_variable cv;
+1 -1
View File
@@ -520,7 +520,7 @@ namespace {
X x;
std::thread t1, t2;
boost::compat::latch l(2);
boost::latch l(2);
std::vector<std::string> strs(values.size());
t1 = std::thread([&l, &values, &x, &strs] {
+4 -4
View File
@@ -84,7 +84,7 @@ void insert_exception_test(T*, Inserter insert, test::random_generator gen)
test::random_values<T> v(10, gen);
T x;
EXCEPTION_LOOP(insert_exception_test_impl(x, generate(insert, x), v))
EXCEPTION_LOOP(insert_exception_test_impl(x, generate(insert, x), v));
}
}
@@ -100,7 +100,7 @@ void insert_rehash_exception_test(
rehash_prep(x);
test::random_values<T> v2(5, gen);
EXCEPTION_LOOP(insert_exception_test_impl(x, generate(insert, x), v2))
EXCEPTION_LOOP(insert_exception_test_impl(x, generate(insert, x), v2));
}
}
@@ -458,7 +458,7 @@ void insert_range_exception_test(T*, test::random_generator gen)
test::random_values<T> v(10, gen);
T x;
EXCEPTION_LOOP(insert_range_exception_test_impl(x, v))
EXCEPTION_LOOP(insert_range_exception_test_impl(x, v));
}
}
@@ -470,7 +470,7 @@ void insert_range_rehash_exception_test(T*, test::random_generator gen)
rehash_prep(x);
test::random_values<T> v2(5, gen);
EXCEPTION_LOOP(insert_range_exception_test_impl(x, v2))
EXCEPTION_LOOP(insert_range_exception_test_impl(x, v2));
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ namespace test {
}
}
#endif
}
};
// Check that size matches up.

Some files were not shown because too many files have changed in this diff Show More