Compare commits

...

144 Commits

Author SHA1 Message Date
Andrey Semashev 608459ab7c Increased BOOST_THREAD_TEST_TIME_MS yet more because of test failures on Windows. 2026-07-03 21:57:51 +03:00
Andrey Semashev 3f285e5600 Fixed more MSVC warnings about variables shadowing other variables. 2026-07-03 19:17:31 +03:00
Andrey Semashev c28c5a4b28 Try to gracefully finish the timed_join test in case of timeout. 2026-07-03 19:17:31 +03:00
Andrey Semashev 0bdc465f89 Fix uninitialized variable warnings in sync queue tests. 2026-07-03 19:17:31 +03:00
Andrey Semashev aeabeffe4d Silence compiler warnings about unused variables. 2026-07-03 19:17:31 +03:00
Andrey Semashev 6fdc4aa10d Fix mutex assignment tests to actually test that assignment is prohibited.
Previously, mutex assignment tests were copies of the copy constructor
tests and did not verify that the assignment operator was deleted. Fix this.
2026-07-03 19:17:31 +03:00
Andrey Semashev 65410ba739 Reduced OMP thread count to avoid test failures due to resource exhaustion. 2026-07-03 19:17:31 +03:00
Andrey Semashev 171eb5811e Enable OpenMP on gcc for test_9856.
By default, OpenMP is not enabled in gcc, which means the test is run
sequentially and compiler warnings about an unsupported #pragma. Enable
OpenMP for gcc and this particular test.
2026-07-03 14:16:17 +03:00
Andrey Semashev 03db328308 Increased max time differences in tests to improve CI reliability.
Increased BOOST_THREAD_TEST_TIME_MS (a.k.a. max_diff) threshold that is
used in many tests for checking wakeup time delays to 600 ms on systems
other than Linux. This is to account increased delays on VMs that are
used to run CI on BSD systems, which occasionally cause excessively long
latencies in thread communication and wakeups.
2026-07-03 02:45:45 +03:00
Andrey Semashev fbeebd66eb On OpenBSD, disable thread ctor tests that throw from operator new.
The tests crash with SIGSEGV when operator new throws for unknown
reason. The constructor itself works as other, non-throwing tests pass.
2026-07-03 02:40:40 +03:00
Andrey Semashev 5a5554a3a6 Avoid recursively throwing an exception from a custom operator new.
Allocating an exception object may recursively call our custom operator
new, which would result in an infinite recursion and a crash. So only
initiate the throw when the operator is called non-recursively.
Otherwise, let the memory allocation proceed using malloc.
2026-07-03 02:40:40 +03:00
Andrey Semashev 031406d2f3 Removed exception specification from custom operator new overrides.
The specifications are not necessary since C++11 anyway, and we
no longer support C++03.
2026-07-03 02:40:40 +03:00
Andrey Semashev 1ce6bceadf Added checks for the malloc call results in operator new.
The operator new is not supposed to return null pointers, so throw
bad_alloc when malloc returns null. This should avoid segmentation
faults if malloc fails.
2026-07-03 02:40:40 +03:00
Andrey Semashev 55cbdeefe4 Silenced unused variable warning. 2026-07-03 02:40:40 +03:00
Andrey Semashev 04da999e57 Silenced unused variable warnings. 2026-07-03 02:40:40 +03:00
Andrey Semashev 884ce13ddd Fix uninitialized variable warnings. 2026-07-03 02:40:40 +03:00
Andrey Semashev 2f9ffdbb63 Removed unused local variables to avoid clang warnings. 2026-07-03 02:40:40 +03:00
Andrey Semashev 53d49020f6 Fix deprecated implicit copy constructor warning in example. 2026-07-03 02:40:40 +03:00
Andrey Semashev 79ebce2326 Provide a user-refined copy constructor in check_flag.
This avoids a clang warning about the implicit copy constructor
being deprecated when a user-defined assignment operator is provided.
2026-07-03 02:40:40 +03:00
Andrey Semashev 78190abb18 Avoid relying on timeouts in when_all/when_any tests.
Use thread barriers to synchronize between the main and async threads
instead of relying on timeouts. This should make these tests more
reliable in CI.
2026-07-03 02:40:40 +03:00
Andrey Semashev 3b4615d9e7 Increased timeouts in condition variable notify tests.
Also made reading the waiting flag thread-safe in the notify tests.
2026-07-03 02:40:40 +03:00
Andrey Semashev 7bcb46a9c7 Avoid relying on timeouts in try_lock_until tests for lock types.
Directly compare the absolute timeouts that are passed to try_lock_until
calls with the expected values. This makes the tests more reliable.
2026-07-03 02:40:40 +03:00
Andrey Semashev c8c283c1e7 Adjusted timeouts in wait tests for futures to improve CI reliability. 2026-07-03 02:40:22 +03:00
Andrey Semashev d5c457aa4a Increased timeouts in thread tests to avoid test failures in CI. 2026-07-02 11:29:30 +03:00
Andrey Semashev dd60839a4e Added multiple attemps of timed waits on a cv in mutex lock tests.
Condition variable timed waits may occasionally return true even if
noone notifies on the variable, which breaks the tests that expect
a timeout. This is considered as spurious wakeups. Add a few attempts
at waiting, which should significantly reduce the likelyhood of
test failures.
2026-07-02 11:29:30 +03:00
Andrey Semashev fc290ec4be Renamed global variables to avoid name clashes with local variables.
This should silence MSVC warnings about local variables in various
places shadowing global variables in the tests.
2026-07-02 11:29:30 +03:00
Andrey Semashev b140c29da3 Use barriers in timed try_join tests.
Use thread barriers to synchronize between test threads to improve
test reliability.
2026-07-02 11:29:29 +03:00
Andrey Semashev 559143bde2 Added timeout grace period to condition variable notify tests.
This should reduce the likelihood of test failures due to timeouts.
2026-07-02 11:29:29 +03:00
Andrey Semashev ef5505e0a1 Join test threads before checking for notification count.
In condition variable notification tests, join the test threads
before making the final check for the number of notifications instead
of relying on timeouts. This should make the tests more reliable,
especially on Windows.
2026-07-01 18:43:31 +03:00
Andrey Semashev 07a7ded841 Reworked GitHub Actions CI config.
Removed usage of actions/checkout which breaks for older compilers due
to dependency on a new Node.js version. Use curl to download Boost
sources.

Removed obsolete GitHub Actions images, added new compilers and more
C++ versions to test. Added jobs for more target operating systems.

Updated environment setup scripts for better performance and
reliability.
2026-07-01 18:43:24 +03:00
Andrey Semashev 375ba39cf9 Fixed code indentation. 2026-06-29 13:19:38 +03:00
Andrey Semashev 48929e4281 Added missing includes of no_exceptions_support.hpp. 2026-06-29 13:13:29 +03:00
Andrey Semashev 07b93da337 Merge pull request #419 from mkruskal-google/patch-1
Use no-exceptions-friendly macros for try/catch block
2026-06-29 13:06:46 +03:00
Mike Kruskal 072ee46e8a Use no-exceptions-friendly macros for try/catch block
This fixes build breakages when -fno-exceptions is used
2026-06-17 21:03:48 -07:00
Andrey Semashev ac15f907be Fix warnings about missing sized deallocation operator in C++14 mode. 2026-02-06 15:45:40 +03:00
Andrey Semashev e2f6e8789f Fixed uninitialized variable warnings. 2026-02-06 15:21:11 +03:00
Andrey Semashev 24917577d7 Silence unused variable warnings. 2026-02-06 15:14:21 +03:00
Andrey Semashev 6da5c6d418 Updated no_exceptions_support.hpp include to the up-to-date location. 2026-02-06 15:08:13 +03:00
Andrey Semashev de9eb0ee7d Fix signed/unsigned a mismatch warning. 2026-02-06 15:06:51 +03:00
Andrey Semashev f19c0d3b56 Removed usage of deprecated Boost.Test header. 2026-02-06 15:05:38 +03:00
Andrey Semashev 3d95d2366e Optimize run_it construction/assignment from rvalue references.
Also fix code indentation.
2026-02-06 14:58:10 +03:00
Andrey Semashev ed7171099b Silence MSVC warning about unreferenced formal parameter.
Closes https://github.com/boostorg/thread/pull/382.
2026-02-06 14:34:14 +03:00
Andrey Semashev 36f63a1b63 Merge pull request #331 from marcusb/patch-1
Non-template function needs inline
2026-02-06 14:05:38 +03:00
Andrey Semashev 2a953f1c4b Merge pull request #309 from Lastique/fix_bind_warnings
Cleanup header includes
2026-02-06 14:04:41 +03:00
Andrey Semashev c34d1fd2d9 Merge pull request #327 from giomasce-throwaway/develop
Fix typos in copyright headers.
2026-02-06 14:00:01 +03:00
Andrey Semashev be42bd8d10 Merge pull request #398 from georgthegreat/patch-1
Use forward slashes to separate include files
2026-02-06 13:58:36 +03:00
Andrey Semashev 45e77a932f Merge pull request #401 from bazelboost/add-missing-assert-header
add missing assert header in pthreads_helpers.hpp
2026-02-06 13:57:07 +03:00
Andrey Semashev b712fac6cc Merge pull request #417 from Lastique/feature/remove_static_assert
Remove dependencies on Boost.StaticAssert
2026-02-06 13:55:25 +03:00
Andrey Semashev ca6b6affec Remove dependencies on Boost.StaticAssert.
Boost.StaticAssert has been merged into Boost.Config, so remove
the dependency.
2026-01-22 19:47:42 +03:00
Peter Dimov a1f89c9518 Merge pull request #403 from grafikrobot/modular
Add support for modular build structure.
2025-05-02 19:21:55 +03:00
Rene Rivera 28d58852bb Move the include usage req to the library build target. 2025-04-14 20:26:31 -05:00
Rene Rivera 4e0a88853a Sync from upstream. 2025-04-04 21:39:22 -05:00
Peter Dimov 5d68c9c42c Merge pull request #408 from arvid-norlander/bugfix/fix-build-on-clang-19
Fix build on clang-19
2025-03-12 04:05:27 +02:00
Peter Dimov b3183638cb Update ci.yml 2025-03-12 03:19:41 +02:00
Peter Dimov 48482ff696 Apply Node20 workaround 2024-12-15 20:49:55 +02:00
Peter Dimov 76411e5918 Update ci.yml 2024-12-15 20:49:55 +02:00
Arvid Norlander 49ccf9c30a Fix build on clang-19 (which checks more things in uninstantiated templates)
Fixes issue #402
2024-11-08 16:48:43 +01:00
Rene Rivera 814ed9f341 Update build deps. 2024-08-09 22:26:06 -05:00
Rene Rivera 82aa252a9e Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:22 -05:00
Rene Rivera b1ff784e51 Update copyright dates. 2024-07-20 22:52:03 -05:00
Rene Rivera e6e4e53807 Bump B2 require to 5.2 2024-06-14 11:33:56 -05:00
Rene Rivera 0fc00ec05c Update dependencies. 2024-05-13 21:47:48 -05:00
Rene Rivera 435a623e48 Add requires-b2 check to top-level build file. 2024-05-05 09:00:01 -05:00
Ezekiel Warren 0a8c93842e fix: modify pthread_helpers adding missing assert header 2024-04-30 00:18:27 -07:00
Rene Rivera ca4b54f96c Add missing NO_LIB usage requirements. 2024-04-28 20:17:11 -05:00
Rene Rivera 43bfe9cbd2 Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:16:00 -05:00
Rene Rivera 691b64d5aa Put back removing qualified boostcpp tag. As we need it until the Jamroot removes the qualified tag. 2024-03-17 18:34:13 -05:00
Rene Rivera e2de571359 Make the library modular usable. 2024-03-11 08:38:17 -05:00
Yuriy Chernyshov 8811487643 Use forward slashes to separate include files
We use automatic dependency tracking for #includes, and wrl includes have to be tracked differently whenever we are cross-compiling the code.

This PR unifies such tracking. Forward slashes work just fine on Windows.
2024-02-04 13:03:02 +01:00
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
Marcus Better 7e2cd262ce Non-template function needs inline
This is to prevent multiple definition of the symbol when the file is included from multiple modules.
2020-12-07 21:23:44 -05:00
Giovanni Mascellani 637ceec996 Fix typos in copyright headers. 2020-10-11 17:34:08 +02: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
Peter Dimov 49ece352b3 Update appveyor.yml 2020-04-07 05:17:17 +03:00
Peter Dimov 116e8f6eb8 Update appveyor.yml 2020-04-07 01:42:28 +03:00
Peter Dimov 66892e5ddd Update appveyor.yml 2020-04-07 00:53:19 +03:00
Peter Dimov 42a48f4b03 Update appveyor.yml 2020-04-06 19:21:50 +03:00
Peter Dimov f33abfd621 Apply fixes for MinGW 2020-04-06 18:57:29 +03:00
Peter Dimov 0277d357ae Update appveyor.yml 2020-04-06 18:49:08 +03:00
Peter Dimov e18ae7b173 Update appveyor.yml 2020-04-06 12:01:22 +03:00
Peter Dimov 119009f2d1 Increase BOOST_THREAD_TEST_TIME on Mac and Cygwin 2020-04-06 11:56:49 +03:00
Peter Dimov 9eee38db94 Try -j3 on Travis to see if it improves build times 2020-04-05 21:34:12 +03:00
Peter Dimov 3e59ecec49 Decrease the number of tested cxxstd levels 2020-04-05 16:56:02 +03:00
Peter Dimov b1842da010 Fix g++ version checks 2020-04-05 15:16:35 +03:00
Peter Dimov b0da8e291b Remove 14/1z from clang 3.5 2020-04-05 15:13:25 +03:00
Peter Dimov 1d436f9030 Add more 'quick' Travis configurations (that only test the headers) 2020-04-05 05:10:51 +03:00
Andrey Semashev 8ebd61c280 Avoid relying on implicit copy constructor/operator deprecated in C++11.
C++11 deprecates implicit default copy constructors and operators if the class
has user-defined destructor or copy constructor/operator. gcc 9 generates
warnings when this deprecated language feature is used. This commit fixes that
by providing user-defained copy constructors/operators where needed. The
added definitions are equivalent to the implicitly generated by the compiler.

For thread::id, removed copy constructor to allow the compiler generate all
set of constructors and assignment operators, including move.
2020-04-05 02:17:14 +03:00
Andrey Semashev ee609e8806 Cleanup header includes.
1. Make inclusion of boost/bind/bind.hpp conditional in some cases, when the
   code actually conditionally uses boost::bind. Reduces compile-time overhead
   and fixes https://github.com/boostorg/thread/issues/307.

2. Remove some unnecessary uses of boost::ref. This allows to avoid including
   boost/core/ref.hpp in a few places, and avoids the associated template
   instantiation overhead in others.

3. Replace deprecated header includes with the more recent alternatives. For
   example: boost/detail/lightweight_test.hpp -> boost/core/lightweight_test.hpp,
   boost/ref.hpp -> boost/core/ref.hpp.

4. Replace some blanket includes with the more fine-grained ones. For example,
   boost/utility.hpp, boost/atomic.hpp. This reduces compile time overhead.

5. Add some missing includes, for example, boost/core/ref.hpp and
   boost/type_traits/is_same.hpp.

6. Replace uses of std::is_same with boost::is_same (with the corresponding
   included header) since the standard type_traits header presence and validity
   is not tested by the code. Using boost::is_same makes the code more portable.
2020-04-05 01:51:58 +03:00
Peter Dimov c13beec81c Change <boost/bind.hpp> includes to <boost/bind/bind.hpp> to avoid deprecation warning 2020-04-04 19:57:59 +03: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
449 changed files with 4749 additions and 2971 deletions
File diff suppressed because it is too large Load Diff
+191 -253
View File
@@ -4,13 +4,7 @@
language: cpp
sudo: false
python: "2.7"
os:
- linux
- osx
os: linux
branches:
only:
@@ -29,123 +23,88 @@ matrix:
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++11 SELF_CONTAINED_HEADER_TESTS=1
# - os: linux
# compiler: g++-4.7
# env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11
# addons:
# apt:
# packages:
# - g++-4.7
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-4.8
# env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11
# addons:
# apt:
# packages:
# - g++-4.8
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-4.9
# env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11
# addons:
# apt:
# packages:
# - g++-4.9
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-5
# env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++98
# addons:
# apt:
# packages:
# - g++-5
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-5
# env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11
# addons:
# apt:
# packages:
# - g++-5
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-5
# env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14
# addons:
# apt:
# packages:
# - g++-5
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-5
# env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++1z
# addons:
# apt:
# packages:
# - g++-5
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-6
# env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++98
# addons:
# apt:
# packages:
# - g++-6
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-6
# env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11
# addons:
# apt:
# packages:
# - g++-6
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-6
# env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14
# addons:
# apt:
# packages:
# - g++-6
# sources:
# - ubuntu-toolchain-r-test
#
# - os: linux
# compiler: g++-6
# env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z
# addons:
# apt:
# packages:
# - g++-6
# sources:
# - ubuntu-toolchain-r-test
compiler: g++-4.4
env: TOOLSET=gcc CXXSTD=98,0x HEADERS_ONLY=1
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc CXXSTD=98,0x HEADERS_ONLY=1
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc CXXSTD=03,11 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc CXXSTD=03,11 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc CXXSTD=03,11 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc CXXSTD=03
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc CXXSTD=14,1z HEADERS_ONLY=1
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++98
env: TOOLSET=gcc CXXSTD=14,17 HEADERS_ONLY=1
addons:
apt:
packages:
@@ -154,196 +113,177 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++11
compiler: g++-8
env: TOOLSET=gcc CXXSTD=14,17 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-7
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc CXXSTD=14
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc CXXSTD=17
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++14
compiler: clang++-3.5
env: TOOLSET=clang CXXSTD=03,11 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-7
- clang-3.5
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++1z
compiler: clang++-3.6
env: TOOLSET=clang CXXSTD=03,11,14 HEADERS_ONLY=1
addons:
apt:
packages:
- g++-7
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang CXXSTD=03,11,14 HEADERS_ONLY=1
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang CXXSTD=03,11,14 HEADERS_ONLY=1
addons:
apt:
packages:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang CXXSTD=03,11,14,1z HEADERS_ONLY=1
addons:
apt:
packages:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
# - os: linux
# compiler: clang++-3.5
# env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11
# addons:
# apt:
# packages:
# - clang-3.5
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.5#
#
# - os: linux
# compiler: clang++-3.6
# env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11
# addons:
# apt:
# packages:
# - clang-3.6
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.6
#
# - os: linux
# compiler: clang++-3.7
# env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11
# addons:
# apt:
# packages:
# - clang-3.7
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.7
#
# - os: linux
# compiler: clang++-3.8
# env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11
# addons:
# apt:
# packages:
# - clang-3.8
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.8
#
# - os: linux
# compiler: clang++-3.8
# env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14
# addons:
# apt:
# packages:
# - clang-3.8
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.8
#
# - os: linux
# compiler: clang++-3.8
# env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z
# addons:
# apt:
# packages:
# - clang-3.8
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.8
#
# - os: linux
# compiler: clang++-3.9
# env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11
# addons:
# apt:
# packages:
# - clang-3.9
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.9
#
# - os: linux
# compiler: clang++-3.9
# env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14
# addons:
# apt:
# packages:
# - clang-3.9
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.9
#
# - os: linux
# compiler: clang++-3.9
# env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z
# addons:
# apt:
# packages:
# - clang-3.9
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.9
#
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++98
env: TOOLSET=clang CXXSTD=03,11,14,1z HEADERS_ONLY=1
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++11
compiler: clang++-5.0
env: TOOLSET=clang CXXSTD=03,11,14,1z HEADERS_ONLY=1
addons:
apt:
packages:
- clang-4.0
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++14
compiler: clang++-6.0
env: TOOLSET=clang CXXSTD=14,17 HEADERS_ONLY=1
addons:
apt:
packages:
- clang-4.0
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++1z
compiler: clang++-7
env: TOOLSET=clang CXXSTD=14,17,2a HEADERS_ONLY=1
addons:
apt:
packages:
- clang-4.0
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang CXXSTD=14,17,2a HEADERS_ONLY=1
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
compiler: clang++-9
env: TOOLSET=clang CXXSTD=14
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-9
env: TOOLSET=clang CXXSTD=17
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++98 SELF_CONTAINED_HEADER_TESTS=1
env: TOOLSET=clang CXXSTD=98
# - os: osx
# compiler: clang++
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
# env: TOOLSET=clang CXXSTD=11
# - os: osx
# compiler: clang++
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14
# env: TOOLSET=clang CXXSTD=14
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z
env: TOOLSET=clang CXXSTD=1z
install:
- GIT_FETCH_JOBS=8
@@ -364,10 +304,8 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- if [ -z "$SELF_CONTAINED_HEADER_TESTS" ]; then export BOOST_THREAD_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS=1; fi
- ./b2 -j $BUILD_JOBS -l60 libs/thread/test toolset=$TOOLSET
echo "using $TOOLSET : : $TRAVIS_COMPILER ;" > ~/user-config.jam
- ./b2 -j3 -l60 libs/thread/test${HEADERS_ONLY:+//test_self_contained_headers} toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
+99
View File
@@ -0,0 +1,99 @@
# 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::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()
+34 -27
View File
@@ -13,39 +13,46 @@ branches:
- develop
- /feature\/.*/
image: Visual Studio 2015
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
TOOLSET: msvc-12.0
SELF_CONTAINED_HEADER_TESTS: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
- TOOLSET: msvc-14.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 17
VARIANT: debug
- TOOLSET: msvc-14.1
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
VARIANT: release
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: msvc-14.2
CXXSTD: 17
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
CXXSTD: 14
SELF_CONTAINED_HEADER_TESTS: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
VARIANT: release
- ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 14
SELF_CONTAINED_HEADER_TESTS: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
VARIANT: debug
- ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 14
SELF_CONTAINED_HEADER_TESTS: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
VARIANT: debug
- ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
TOOLSET: gcc
CXXSTD: 14
SELF_CONTAINED_HEADER_TESTS: 1
VARIANT: release
install:
- set GIT_FETCH_JOBS=8
@@ -67,7 +74,7 @@ build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if "%SELF_CONTAINED_HEADER_TESTS%" == "" set BOOST_THREAD_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS=1
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% --abbreviate-paths libs/thread/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
- if not "%VARIANT%" == "" set VARIANT=variant=%VARIANT%
- b2 -j2 --abbreviate-paths libs/thread/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %VARIANT%
+45
View File
@@ -0,0 +1,45 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# 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)
require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/atomic//boost_atomic
/boost/bind//boost_bind
/boost/chrono//boost_chrono
/boost/concept_check//boost_concept_check
/boost/config//boost_config
/boost/container//boost_container
/boost/container_hash//boost_container_hash
/boost/core//boost_core
/boost/date_time//boost_date_time
/boost/exception//boost_exception
/boost/function//boost_function
/boost/io//boost_io
/boost/move//boost_move
/boost/optional//boost_optional
/boost/predef//boost_predef
/boost/preprocessor//boost_preprocessor
/boost/smart_ptr//boost_smart_ptr
/boost/system//boost_system
/boost/throw_exception//boost_throw_exception
/boost/tuple//boost_tuple
/boost/type_traits//boost_type_traits
/boost/utility//boost_utility
/boost/winapi//boost_winapi ;
project /boost/thread
;
explicit
[ alias boost_thread : build//boost_thread ]
[ alias all : boost_thread example test ]
;
call-if : boost-library thread
: install boost_thread
;
+20 -10
View File
@@ -35,18 +35,22 @@
import os ;
import indirect ;
import path ;
import configure ;
import configure ;
import threadapi-feature ;
exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ;
project boost/thread
project
: source-location ../src
: common-requirements
<library>$(boost_dependencies)
<include>../include
: requirements <threading>multi
#<link>static:<define>BOOST_THREAD_STATIC_LINK=1
#<link>shared:<define>BOOST_THREAD_DYN_LINK=1
<link>static:<define>BOOST_THREAD_BUILD_LIB=1
<link>shared:<define>BOOST_THREAD_BUILD_DLL=1
-<tag>@%boostcpp.tag
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@$(__name__).tag
<toolset>gcc:<cxxflags>-Wno-long-long
@@ -139,6 +143,7 @@ project boost/thread
#<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
#<define>BOOST_SYSTEM_NO_DEPRECATED
#<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
<define>BOOST_THREAD_NO_LIB=1
;
rule tag ( name : type ? : property-set )
@@ -156,8 +161,15 @@ rule tag ( name : type ? : property-set )
}
# forward to the boost tagging rule
return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
$(result) : $(type) : $(property-set) ] ;
if $(BOOST_JAMROOT_MODULE)
{
return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
$(result) : $(type) : $(property-set) ] ;
}
else
{
return $(result) ;
}
}
rule win32_pthread_paths ( properties * )
@@ -269,10 +281,10 @@ rule requirements ( properties * )
}
}
result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
if ! [ configure.builds has_atomic_flag_lockfree
: $(properties) : "lockfree boost::atomic_flag" ] {
result += <library>/boost/atomic//boost_atomic ;
}
if ! [ configure.builds has_atomic_flag_lockfree
: $(properties) : "lockfree boost::atomic_flag" ] {
result += <library>/boost/atomic//boost_atomic ;
}
} else {
if <threadapi>win32 in $(properties)
{
@@ -315,5 +327,3 @@ lib boost_thread
<link>static:<define>BOOST_THREAD_USE_LIB=1
<conditional>@usage-requirements
;
boost-install boost_thread ;
+1 -1
View File
@@ -1,5 +1,5 @@
[/
(C) Copyright 20012 Vicente J. Botet Escriba.
(C) Copyright 2012 Vicente J. Botet Escriba.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
+1 -1
View File
@@ -1,6 +1,6 @@
[/
(C) Copyright 2007-12 Anthony Williams.
(C) Copyright 20012 Vicente J. Botet Escriba.
(C) Copyright 2012 Vicente J. Botet Escriba.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
+1 -1
View File
@@ -1,6 +1,6 @@
[/
(C) Copyright 2008-9 Anthony Williams.
(C) Copyright 12 Vicente J. Botet Escriba.
(C) Copyright 2012 Vicente J. Botet Escriba.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
+1 -1
View File
@@ -4,7 +4,7 @@
# 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)
project boost/thread/example
project
: requirements <library>../build//boost_thread <threading>multi
;
+8 -8
View File
@@ -112,21 +112,21 @@ int main()
#if __cplusplus > 201103L
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
int i = 0;
boost::future<int&> f = boost::make_ready_future(std::ref(i));
int x = 0;
boost::future<int&> f = boost::make_ready_future(std::ref(x));
std::cout << f.get() << std::endl;
}
#endif
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
int i = 0;
boost::future<int&> f = boost::make_ready_future(boost::ref(i));
int x = 0;
boost::future<int&> f = boost::make_ready_future(boost::ref(x));
std::cout << f.get() << std::endl;
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
const int i = 0;
boost::future<int const&> f = boost::make_ready_future(boost::cref(i));
const int x = 0;
boost::future<int const&> f = boost::make_ready_future(boost::cref(x));
std::cout << f.get() << std::endl;
}
{
@@ -142,12 +142,12 @@ int main()
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
std::cout << "ERRORRRRR " << ex.what() << std::endl;
return 1;
}
catch (...)
{
std::cout << "ERRORRRRR "<<"ERRORRRRR exception thrown" << std::endl;
std::cout << "ERRORRRRR ERRORRRRR exception thrown" << std::endl;
return 2;
}
return 0;
+4 -4
View File
@@ -8,7 +8,7 @@
#include <boost/thread/thread.hpp>
#include <iostream>
boost::mutex io_mutex; // The iostreams are not guaranteed to be thread-safe!
boost::mutex g_io_mutex; // The iostreams are not guaranteed to be thread-safe!
class counter
{
@@ -25,12 +25,12 @@ private:
int count;
};
counter c;
counter g_counter;
void change_count()
{
int i = c.increment();
boost::unique_lock<boost::mutex> scoped_lock(io_mutex);
int i = g_counter.increment();
boost::unique_lock<boost::mutex> scoped_lock(g_io_mutex);
std::cout << "count == " << i << std::endl;
}
+8 -8
View File
@@ -10,23 +10,23 @@
#include <boost/thread/once.hpp>
#include <cassert>
int value=0;
int g_value=0;
#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
static boost::once_flag once;
//static boost::once_flag once2 = BOOST_ONCE_INIT;
static boost::once_flag g_once;
//static boost::once_flag g_once2 = BOOST_ONCE_INIT;
#else
static boost::once_flag once = BOOST_ONCE_INIT;
//static boost::once_flag once2 = once;
static boost::once_flag g_once = BOOST_ONCE_INIT;
//static boost::once_flag g_once2 = g_once;
#endif
void init()
{
++value;
++g_value;
}
void thread_proc()
{
boost::call_once(&init, once);
boost::call_once(&init, g_once);
}
int main()
@@ -35,5 +35,5 @@ int main()
for (int i=0; i<5; ++i)
threads.create_thread(&thread_proc);
threads.join_all();
assert(value == 1);
assert(g_value == 1);
}
+3
View File
@@ -54,6 +54,7 @@ void consumer(
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull(r);
//sbq >> r;
@@ -77,6 +78,7 @@ void consumer2(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
@@ -97,6 +99,7 @@ void consumer3(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
+3
View File
@@ -57,6 +57,7 @@ void consumer(
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull(r);
//sbq >> r;
@@ -80,6 +81,7 @@ void consumer2(the_ostream &/*mos*/, boost::queue_front<int> sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
@@ -100,6 +102,7 @@ void consumer3(the_ostream &/*mos*/, boost::queue_front<int> sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
+2
View File
@@ -55,6 +55,7 @@ void consumer(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull_front(r);
//sbq >> r;
@@ -77,6 +78,7 @@ void consumer2(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull_front(r);
if (queue_op_status::closed == st) break;
+2 -2
View File
@@ -28,11 +28,11 @@ private:
int count;
};
counter c;
counter g_counter;
void change_count()
{
//std::cout << "count == " << c.increment() << std::endl;
//std::cout << "count == " << g_counter.increment() << std::endl;
}
int main(int, char*[])
+1
View File
@@ -26,6 +26,7 @@ struct func
int& i;
func(int& i_):i(i_){}
func(func const& that):i(that.i){}
void operator()()
{
+20 -20
View File
@@ -28,9 +28,9 @@ enum game_state
BOTH_PLAYERS_GONE
};
int state;
boost::mutex mutex;
boost::condition cond;
int g_state;
boost::mutex g_mutex;
boost::condition g_cond;
const char* player_name(int state)
{
@@ -44,29 +44,29 @@ const char* player_name(int state)
void player(int active)
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
int other = active == PLAYER_A ? PLAYER_B : PLAYER_A;
while (state < GAME_OVER)
while (g_state < GAME_OVER)
{
//std::cout << player_name(active) << ": Play." << std::endl;
state = other;
cond.notify_all();
g_state = other;
g_cond.notify_all();
do
{
cond.wait(lock);
if (state == other)
g_cond.wait(lock);
if (g_state == other)
{
std::cout << "---" << player_name(active)
<< ": Spurious wakeup!" << std::endl;
}
} while (state == other);
} while (g_state == other);
}
++state;
++g_state;
std::cout << player_name(active) << ": Gone." << std::endl;
cond.notify_all();
g_cond.notify_all();
}
struct thread_adapt
@@ -100,7 +100,7 @@ private:
int main()
{
state = START;
g_state = START;
boost::thread thrda(&player, PLAYER_A);
boost::thread thrdb(&player, PLAYER_B);
@@ -110,22 +110,22 @@ int main()
xt.sec += 1;
boost::thread::sleep(xt);
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "---Noise ON..." << std::endl;
}
for (int i = 0; i < 10; ++i)
cond.notify_all();
g_cond.notify_all();
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "---Noise OFF..." << std::endl;
state = GAME_OVER;
cond.notify_all();
g_state = GAME_OVER;
g_cond.notify_all();
do
{
cond.wait(lock);
} while (state != BOTH_PLAYERS_GONE);
g_cond.wait(lock);
} while (g_state != BOTH_PLAYERS_GONE);
}
std::cout << "GAME OVER" << std::endl;
+11 -12
View File
@@ -8,23 +8,22 @@
#include <iostream>
#include <boost/detail/lightweight_test.hpp>
int count = 0;
boost::mutex mutex;
int g_count = 0;
boost::mutex g_mutex;
void increment_count()
{
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "count = " << ++count << std::endl;
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "count = " << ++g_count << std::endl;
}
boost::thread_group threads2;
boost::thread* th2 = 0;
boost::thread_group g_threads2;
void increment_count_2()
{
boost::unique_lock<boost::mutex> lock(mutex);
BOOST_TEST(threads2.is_this_thread_in());
std::cout << "count = " << ++count << std::endl;
boost::unique_lock<boost::mutex> lock(g_mutex);
BOOST_TEST(g_threads2.is_this_thread_in());
std::cout << "count = " << ++g_count << std::endl;
}
int main()
@@ -63,11 +62,11 @@ int main()
}
{
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
boost::thread* th2 = new boost::thread(&increment_count_2);
threads2.add_thread(th2);
g_threads2.add_thread(th2);
}
threads2.join_all();
g_threads2.join_all();
}
return boost::report_errors();
}
+1
View File
@@ -20,6 +20,7 @@ struct func
int& i;
func(int& i_):i(i_){}
func(func const& other):i(other.i){}
void operator()()
{
+4 -4
View File
@@ -8,21 +8,21 @@
#include <boost/thread/tss.hpp>
#include <cassert>
boost::thread_specific_ptr<int> value;
boost::thread_specific_ptr<int> g_value;
void increment()
{
int* p = value.get();
int* p = g_value.get();
++*p;
}
void thread_proc()
{
value.reset(new int(0)); // initialize the thread's storage
g_value.reset(new int(0)); // initialize the thread's storage
for (int i=0; i<10; ++i)
{
increment();
int* p = value.get();
int* p = g_value.get();
assert(*p == i+1);
(void)(p);
}
+8 -8
View File
@@ -12,18 +12,18 @@
#include <boost/thread/scoped_thread.hpp>
#include <boost/thread/with_lock_guard.hpp>
boost::mutex m; // protection for 'x' and 'std::cout'
int x;
boost::mutex g_mutex; // protection for 'g_x' and 'std::cout'
int g_x = 0;
#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700)
void print_x() {
++x;
std::cout << "x = " << x << std::endl;
++g_x;
std::cout << "x = " << g_x << std::endl;
}
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(m, print_x);
boost::with_lock_guard(g_mutex, print_x);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
}
}
@@ -31,10 +31,10 @@ void job() {
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(
m,
g_mutex,
[]() {
++x;
std::cout << "x = " << x << std::endl;
++g_x;
std::cout << "x = " << g_x << std::endl;
}
);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
@@ -148,7 +148,7 @@ namespace detail
template <class Q, class T,
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
#if defined __GNUC__ && ! defined __clang__
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
@@ -140,7 +140,7 @@ namespace detail
template <class T, class ST,
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
#if defined __GNUC__ && ! defined __clang__
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
@@ -11,7 +11,8 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/core/ref.hpp>
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -187,7 +188,7 @@ namespace detail
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
{
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
if (! empty(lk)) return false; // success
return true; // closed
}
@@ -196,7 +197,7 @@ namespace detail
template <class WClock, class Duration>
queue_op_status sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
{
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
return queue_op_status::timeout;
if (! empty(lk)) return queue_op_status::success;
return queue_op_status::closed;
@@ -11,7 +11,8 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/core/ref.hpp>
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -187,7 +188,7 @@ namespace detail
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
{
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
if (! empty(lk)) return false; // success
return true; // closed
}
@@ -196,7 +197,7 @@ namespace detail
template <class WClock, class Duration>
queue_op_status sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
{
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
return queue_op_status::timeout;
if (! empty(lk)) return queue_op_status::success;
return queue_op_status::closed;
@@ -148,7 +148,7 @@ namespace detail
template <class Q, class T,
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
#if defined __GNUC__ && ! defined __clang__
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
@@ -140,7 +140,7 @@ namespace detail
template <class T, class ST,
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
#if defined __GNUC__ && ! defined __clang__
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
+1 -24
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
+1 -14
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
+1 -14
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
@@ -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
@@ -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
@@ -9,8 +9,6 @@
#ifndef BOOST_CSBL_MEMORY_CONFIG_HPP
#define BOOST_CSBL_MEMORY_CONFIG_HPP
#include <boost/config.hpp>
#include <memory>
#endif // header
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+2 -26
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
+1 -18
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
+1 -14
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
+1 -1
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
+11 -4
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)
@@ -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
@@ -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
+28 -5
View File
@@ -30,7 +30,6 @@
#include <algorithm>
#include <boost/core/ref.hpp>
#include <boost/cstdint.hpp>
#include <boost/bind.hpp>
#include <stdlib.h>
#include <memory>
#include <boost/core/enable_if.hpp>
@@ -47,6 +46,8 @@
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#include <tuple>
#else
#include <boost/bind/bind.hpp>
#endif
#include <boost/config/abi_prefix.hpp>
@@ -601,6 +602,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 +616,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;
@@ -637,10 +649,6 @@ namespace boost
#endif
{}
id(const id& other) BOOST_NOEXCEPT :
thread_data(other.thread_data)
{}
bool operator==(const id& y) const BOOST_NOEXCEPT
{
return thread_data==y.thread_data;
@@ -708,6 +716,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
@@ -51,7 +51,7 @@ BOOST_THREAD_INLINE_NAMESPACE(v2)
namespace detail
{
void handle_task_region_exceptions(exception_list& errors)
inline void handle_task_region_exceptions(exception_list& errors)
{
try {
throw;
+5 -5
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.
+31 -30
View File
@@ -54,7 +54,7 @@ struct shared_state_base {
#endif
#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#ifdef BOOST_THREAD_USES_CHRONO
#include <boost/chrono/system_clocks.hpp>
#endif
@@ -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>
@@ -393,7 +392,7 @@ namespace boost
is_deferred_=false;
execute(lk);
}
waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
if(rethrow && exception)
{
boost::rethrow_exception(exception);
@@ -420,7 +419,7 @@ namespace boost
return false;
do_callback(lock);
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, this));
}
bool timed_wait_until(boost::system_time const& target_time)
@@ -430,7 +429,7 @@ namespace boost
return false;
do_callback(lock);
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, this));
}
#endif
#ifdef BOOST_THREAD_USES_CHRONO
@@ -443,7 +442,7 @@ namespace boost
if (is_deferred_)
return future_status::deferred;
do_callback(lock);
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, boost::ref(*this))))
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, this)))
{
return future_status::timeout;
}
@@ -940,7 +939,7 @@ namespace boost
join();
#elif defined BOOST_THREAD_ASYNC_FUTURE_WAITS
unique_lock<boost::mutex> lk(this->mutex);
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
#endif
}
@@ -4650,32 +4649,34 @@ namespace detail
shared_ptr<FutureExecutorContinuationSharedState> that_;
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_THREAD_COPYABLE_AND_MOVABLE(run_it)
run_it(run_it const& x) //BOOST_NOEXCEPT
: that_(x.that_)
{}
run_it& operator=(BOOST_THREAD_COPY_ASSIGN_REF(run_it) x) //BOOST_NOEXCEPT
{
if (this != &x) {
that_=x.that_;
}
return *this;
BOOST_THREAD_COPYABLE_AND_MOVABLE(run_it)
run_it(run_it const& x) //BOOST_NOEXCEPT
: that_(x.that_)
{}
run_it& operator=(BOOST_THREAD_COPY_ASSIGN_REF(run_it) x) //BOOST_NOEXCEPT
{
if (this != &x) {
that_=x.that_;
}
// move
run_it(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT
: that_(x.that_)
{
x.that_.reset();
}
run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT {
if (this != &x) {
that_=x.that;
x.that_.reset();
}
return *this;
return *this;
}
// move
run_it(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT
: that_(boost::move(x.that_))
{
}
run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT {
if (this != &x) {
that_ = boost::move(x.that_);
}
return *this;
}
run_it(shared_ptr<FutureExecutorContinuationSharedState> that) : that_(boost::move(that))
{}
#else
run_it(shared_ptr<FutureExecutorContinuationSharedState> that) : that_(that)
{}
#endif
run_it(shared_ptr<FutureExecutorContinuationSharedState> that) : that_ (that) {}
void operator()()
{
@@ -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;
}
}
+6 -3
View File
@@ -19,14 +19,17 @@
#include <boost/thread/detail/delete.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/bind.hpp>
#include <boost/assert.hpp>
#include <boost/config/abi_prefix.hpp>
#include <boost/cstdint.hpp>
#include <pthread.h>
#include <csignal>
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
#include <boost/bind/bind.hpp>
#endif
#include <boost/config/abi_prefix.hpp>
namespace boost
{
+6 -2
View File
@@ -16,8 +16,12 @@
#include <boost/thread/detail/move.hpp>
#include <boost/thread/detail/invoke.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/bind.hpp>
#include <boost/atomic.hpp>
#include <boost/atomic/capabilities.hpp>
#include <boost/atomic/atomic.hpp>
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
#include <boost/bind/bind.hpp>
#endif
#include <boost/config/abi_prefix.hpp>
@@ -9,6 +9,7 @@
#include <boost/thread/detail/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/assert.hpp>
#include <pthread.h>
#include <errno.h>
+17 -17
View File
@@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/static_assert.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -171,7 +171,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, boost::ref(state)));
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, &state));
state.lock_shared();
}
@@ -194,7 +194,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, &state)))
{
return false;
}
@@ -209,7 +209,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, &state)))
{
return false;
}
@@ -230,7 +230,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, &state)))
{
return false;
}
@@ -270,7 +270,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.exclusive_waiting_blocked=true;
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, boost::ref(state)));
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, &state));
state.exclusive=true;
}
@@ -282,7 +282,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.exclusive_waiting_blocked=true;
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, boost::ref(state))))
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, &state)))
{
state.exclusive_waiting_blocked=false;
release_waiters();
@@ -300,7 +300,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.exclusive_waiting_blocked=true;
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, boost::ref(state))))
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, &state)))
{
state.exclusive_waiting_blocked=false;
release_waiters();
@@ -324,7 +324,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.exclusive_waiting_blocked=true;
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, boost::ref(state))))
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, &state)))
{
state.exclusive_waiting_blocked=false;
release_waiters();
@@ -362,7 +362,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, boost::ref(state)));
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, &state));
state.lock_shared();
state.upgrade=true;
}
@@ -374,7 +374,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, &state)))
{
return false;
}
@@ -390,7 +390,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, &state)))
{
return false;
}
@@ -412,7 +412,7 @@ namespace boost
boost::this_thread::disable_interruption do_not_disturb;
#endif
boost::unique_lock<boost::mutex> lk(state_change);
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
{
return false;
}
@@ -457,7 +457,7 @@ namespace boost
boost::unique_lock<boost::mutex> lk(state_change);
state.assert_lock_upgraded();
state.unlock_shared();
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, boost::ref(state)));
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, &state));
state.upgrade=false;
state.exclusive=true;
state.assert_locked();
@@ -511,7 +511,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.assert_lock_upgraded();
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
{
return false;
}
@@ -569,7 +569,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.assert_lock_shared();
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
{
return false;
}
@@ -623,7 +623,7 @@ namespace boost
#endif
boost::unique_lock<boost::mutex> lk(state_change);
state.assert_lock_shared();
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
{
return false;
}
+1 -1
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);
+9
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_);
+4 -4
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);
}
/**
+5
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_);
+27 -27
View File
@@ -158,7 +158,7 @@ public:
#endif
#include <climits>
#include <boost/system/system_error.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
namespace boost {
namespace thread_v2 {
@@ -275,9 +275,9 @@ namespace boost {
inline void shared_mutex::lock()
{
boost::unique_lock<mutex_t> lk(mut_);
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer, boost::ref(*this)));
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer, this));
state_ |= write_entered_;
gate2_.wait(lk, boost::bind(&shared_mutex::no_readers, boost::ref(*this)));
gate2_.wait(lk, boost::bind(&shared_mutex::no_readers, this));
}
inline bool shared_mutex::try_lock()
@@ -298,13 +298,13 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&shared_mutex::no_writer, boost::ref(*this))))
&shared_mutex::no_writer, this)))
{
return false;
}
state_ |= write_entered_;
if (!gate2_.wait_until(lk, abs_time, boost::bind(
&shared_mutex::no_readers, boost::ref(*this))))
&shared_mutex::no_readers, this)))
{
state_ &= ~write_entered_;
return false;
@@ -319,13 +319,13 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
&shared_mutex::no_writer, boost::ref(*this))))
&shared_mutex::no_writer, this)))
{
return false;
}
state_ |= write_entered_;
if (!gate2_.timed_wait(lk, abs_or_rel_time, boost::bind(
&shared_mutex::no_readers, boost::ref(*this))))
&shared_mutex::no_readers, this)))
{
state_ &= ~write_entered_;
return false;
@@ -350,7 +350,7 @@ namespace boost {
inline void shared_mutex::lock_shared()
{
boost::unique_lock<mutex_t> lk(mut_);
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer_no_max_readers, boost::ref(*this)));
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer_no_max_readers, this));
count_t num_readers = (state_ & n_readers_) + 1;
state_ &= ~n_readers_;
state_ |= num_readers;
@@ -376,7 +376,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&shared_mutex::no_writer_no_max_readers, boost::ref(*this))))
&shared_mutex::no_writer_no_max_readers, this)))
{
return false;
}
@@ -393,7 +393,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
&shared_mutex::no_writer_no_max_readers, boost::ref(*this))))
&shared_mutex::no_writer_no_max_readers, this)))
{
return false;
}
@@ -653,9 +653,9 @@ namespace boost {
inline void upgrade_mutex::lock()
{
boost::unique_lock<mutex_t> lk(mut_);
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this)));
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader, this));
state_ |= write_entered_;
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, boost::ref(*this)));
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, this));
}
inline bool upgrade_mutex::try_lock()
@@ -676,13 +676,13 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader, this)))
{
return false;
}
state_ |= write_entered_;
if (!gate2_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_readers, boost::ref(*this))))
&upgrade_mutex::no_readers, this)))
{
state_ &= ~write_entered_;
return false;
@@ -697,13 +697,13 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader, this)))
{
return false;
}
state_ |= write_entered_;
if (!gate2_.timed_wait(lk, abs_or_rel_time, boost::bind(
&upgrade_mutex::no_readers, boost::ref(*this))))
&upgrade_mutex::no_readers, this)))
{
state_ &= ~write_entered_;
return false;
@@ -729,7 +729,7 @@ namespace boost {
inline void upgrade_mutex::lock_shared()
{
boost::unique_lock<mutex_t> lk(mut_);
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this)));
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_max_readers, this));
count_t num_readers = (state_ & n_readers_) + 1;
state_ &= ~n_readers_;
state_ |= num_readers;
@@ -755,7 +755,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this))))
&upgrade_mutex::no_writer_no_max_readers, this)))
{
return false;
}
@@ -772,7 +772,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this))))
&upgrade_mutex::no_writer_no_max_readers, this)))
{
return false;
}
@@ -807,7 +807,7 @@ namespace boost {
inline void upgrade_mutex::lock_upgrade()
{
boost::unique_lock<mutex_t> lk(mut_);
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this)));
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this));
count_t num_readers = (state_ & n_readers_) + 1;
state_ &= ~n_readers_;
state_ |= upgradable_entered_ | num_readers;
@@ -833,7 +833,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this)))
{
return false;
}
@@ -850,7 +850,7 @@ namespace boost {
{
boost::unique_lock<mutex_t> lk(mut_);
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this)))
{
return false;
}
@@ -898,7 +898,7 @@ namespace boost {
boost::unique_lock<mutex_t> lk(mut_);
BOOST_ASSERT(one_or_more_readers());
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader, this)))
{
return false;
}
@@ -906,7 +906,7 @@ namespace boost {
state_ &= ~n_readers_;
state_ |= (write_entered_ | num_readers);
if (!gate2_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_readers, boost::ref(*this))))
&upgrade_mutex::no_readers, this)))
{
++num_readers;
state_ &= ~(write_entered_ | n_readers_);
@@ -953,7 +953,7 @@ namespace boost {
boost::unique_lock<mutex_t> lk(mut_);
BOOST_ASSERT(one_or_more_readers());
if (!gate1_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
&upgrade_mutex::no_writer_no_upgrader, this)))
{
return false;
}
@@ -987,7 +987,7 @@ namespace boost {
count_t num_readers = (state_ & n_readers_) - 1;
state_ &= ~(upgradable_entered_ | n_readers_);
state_ |= write_entered_ | num_readers;
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, boost::ref(*this)));
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, this));
}
inline bool upgrade_mutex::try_unlock_upgrade_and_lock()
@@ -1017,7 +1017,7 @@ namespace boost {
state_ &= ~(upgradable_entered_ | n_readers_);
state_ |= (write_entered_ | num_readers);
if (!gate2_.wait_until(lk, abs_time, boost::bind(
&upgrade_mutex::no_readers, boost::ref(*this))))
&upgrade_mutex::no_readers, this)))
{
++num_readers;
state_ &= ~(write_entered_ | n_readers_);
@@ -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);
+4 -2
View File
@@ -22,7 +22,9 @@
#include <boost/thread/detail/move.hpp>
#include <boost/thread/detail/invoke.hpp>
#include <boost/bind.hpp>
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
#include <boost/bind/bind.hpp>
#endif
#include <boost/config/abi_prefix.hpp>
@@ -152,7 +154,7 @@ namespace boost
{
name_once_mutex(mutex_name,flag_address);
}
return ::boost::detail::win32::create_event(
mutex_name,
::boost::detail::win32::manual_reset_event,
@@ -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;
+3 -2
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"
}
]
+1 -1
View File
@@ -11,8 +11,8 @@
#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/atomic.hpp>
#include <boost/memory_order.hpp>
#include <boost/atomic/atomic.hpp>
#include <pthread.h>
namespace boost
+72 -60
View File
@@ -19,6 +19,9 @@
#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>
#include <boost/core/no_exceptions_support.hpp>
#ifdef __GLIBC__
#include <sys/sysinfo.h>
@@ -33,10 +36,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>
@@ -187,7 +186,7 @@ namespace boost
// Unhandled exceptions still cause the application to terminate
// BOOST_CATCH(...)
// {
// throw;
// throw;
//
// std::terminate();
// }
@@ -214,12 +213,13 @@ namespace boost
interrupt_enabled=false;
#endif
}
~externally_launched_thread() {
BOOST_ASSERT(notify.empty());
notify.clear();
~externally_launched_thread()
{
BOOST_ASSERT(notify.empty());
notify.clear();
//#ifndef BOOST_NO_EXCEPTIONS
BOOST_ASSERT(async_states_.empty());
async_states_.clear();
BOOST_ASSERT(async_states_.empty());
async_states_.clear();
//#endif
}
void run()
@@ -356,7 +356,7 @@ namespace boost
}
else
{
return false;
return false;
}
}
@@ -375,8 +375,8 @@ namespace boost
}
if(!local_thread_info->done)
{
res=false;
return true;
res=false;
return true;
}
do_join=!local_thread_info->join_started;
@@ -439,31 +439,31 @@ namespace boost
namespace this_thread
{
namespace no_interruption_point
{
namespace hidden
namespace no_interruption_point
{
void BOOST_THREAD_DECL sleep_for_internal(const detail::platform_duration& ts)
{
if (ts > detail::platform_duration::zero())
namespace hidden
{
void BOOST_THREAD_DECL sleep_for_internal(const detail::platform_duration& ts)
{
// Use pthread_delay_np or nanosleep whenever possible here in the no_interruption_point
// namespace because they do not provide an interruption point.
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
# if defined(__IBMCPP__) || defined(_AIX)
BOOST_VERIFY(!pthread_delay_np(const_cast<timespec*>(&ts.getTs())));
# else
BOOST_VERIFY(!pthread_delay_np(&ts.getTs()));
# endif
# elif defined(BOOST_HAS_NANOSLEEP)
nanosleep(&ts.getTs(), 0);
# else
// This should never be reached due to BOOST_THREAD_SLEEP_FOR_IS_STEADY
# endif
if (ts > detail::platform_duration::zero())
{
// Use pthread_delay_np or nanosleep whenever possible here in the no_interruption_point
// namespace because they do not provide an interruption point.
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
# if defined(__IBMCPP__) || defined(_AIX)
BOOST_VERIFY(!pthread_delay_np(const_cast<timespec*>(&ts.getTs())));
# else
BOOST_VERIFY(!pthread_delay_np(&ts.getTs()));
# endif
# elif defined(BOOST_HAS_NANOSLEEP)
nanosleep(&ts.getTs(), 0);
# else
// This should never be reached due to BOOST_THREAD_SLEEP_FOR_IS_STEADY
# endif
}
}
}
}
}
}
void yield() BOOST_NOEXCEPT
{
@@ -517,7 +517,7 @@ namespace boost
unsigned thread::physical_concurrency() BOOST_NOEXCEPT
{
#ifdef __linux__
try {
BOOST_TRY {
using namespace std;
ifstream proc_cpuinfo ("/proc/cpuinfo");
@@ -535,24 +535,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;
}
@@ -560,9 +572,10 @@ namespace boost
// Fall back to hardware_concurrency() in case
// /proc/cpuinfo is formatted differently than we expect.
return cores.size() != 0 ? cores.size() : hardware_concurrency();
} catch(...) {
return hardware_concurrency();
} BOOST_CATCH(...) {
return hardware_concurrency();
}
BOOST_CATCH_END
#elif defined(__APPLE__)
int count;
size_t size=sizeof(count);
@@ -776,26 +789,25 @@ namespace boost
BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
{
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
}
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
}
}
//#ifndef BOOST_NO_EXCEPTIONS
namespace detail {
namespace detail
{
void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
{
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->make_ready_at_thread_exit(as);
}
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->make_ready_at_thread_exit(as);
}
}
}
//#endif
}
+27 -6
View File
@@ -29,15 +29,16 @@
#include <stdio.h>
#include <windows.h>
#include <boost/predef/platform.h>
#include <boost/core/no_exceptions_support.hpp>
#if BOOST_PLAT_WINDOWS_RUNTIME
#include <mutex>
#include <atomic>
#include <Activation.h>
#include <wrl\client.h>
#include <wrl\event.h>
#include <wrl\wrappers\corewrappers.h>
#include <wrl\ftm.h>
#include <wrl/client.h>
#include <wrl/event.h>
#include <wrl/wrappers/corewrappers.h>
#include <wrl/ftm.h>
#include <windows.system.threading.h>
#pragma comment(lib, "runtimeobject.lib")
#endif
@@ -577,10 +578,18 @@ namespace boost
} Reason;
} REASON_CONTEXT, *PREASON_CONTEXT;
typedef BOOL (WINAPI *setwaitabletimerex_t)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, PREASON_CONTEXT, ULONG);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4100) // unreferenced formal parameter
#endif
static inline BOOL WINAPI SetWaitableTimerEx_emulation(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
{
return SetWaitableTimer(hTimer, lpDueTime, lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, FALSE);
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 6387) // MSVC sanitiser warns that GetModuleHandleA() might fail
@@ -641,9 +650,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 +748,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)
{
+3 -3
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)
+3 -1
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
+17 -8
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)
+32 -20
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
@@ -110,18 +110,18 @@ project
<toolset>msvc:<cxxflags>/wd6246
;
rule thread-run ( sources )
rule thread-run ( sources : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
[ run $(sources) ../build//boost_thread ]
[ run $(sources) ../build//boost_thread : : : $(reqs) ]
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
: : : : $(sources[1]:B)_lib ]
: : : $(reqs) : $(sources[1]:B)_lib ]
;
}
rule thread-test ( sources )
rule thread-test ( sources : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
@@ -136,14 +136,14 @@ rule thread-test ( sources )
;
}
rule thread-run2 ( sources : name )
rule thread-run2 ( sources : name : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
[ run $(sources) ../build//boost_thread : : :
[ run $(sources) ../build//boost_thread : : : $(reqs)
: $(name) ]
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
: : :
: : : $(reqs)
: $(name)_lib ]
;
}
@@ -268,16 +268,15 @@ rule generate_self_contained_header_tests
if ! [ os.environ BOOST_THREAD_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS ]
{
local headers_path = [ path.make $(BOOST_ROOT)/libs/thread/include/boost/thread ] ;
for file in [ path.glob-tree $(headers_path) : *.hpp : detail pthread win32 ]
for file in [ glob-tree-ex ../include/boost/thread : *.hpp : detail pthread win32 ]
{
local rel_file = [ path.relative-to $(headers_path) $(file) ] ;
local rel_file = [ path.relative-to ../include/boost/thread $(file) ] ;
# Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end.
# All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes.
local test_name = [ regex.replace ~hdr/$(rel_file) "/" "-" ] ;
#ECHO $(rel_file) ;
all_rules += [ compile self_contained_header.cpp : <define>"BOOST_THREAD_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(test_name) ] ;
all_rules += [ compile self_contained_header.cpp : <define>"BOOST_THREAD_TEST_HEADER=$(rel_file)" <define>"BOOST_THREAD_TEST_POST_WINDOWS_H" <dependency>$(file) <conditional>@windows-cygwin-specific : $(test_name)-post_winh ] ;
all_rules += [ compile self_contained_header.cpp : <define>"BOOST_THREAD_TEST_HEADER=$(rel_file)" <dependency>$(file) <use>../build//boost_thread : $(test_name) ] ;
all_rules += [ compile self_contained_header.cpp : <define>"BOOST_THREAD_TEST_HEADER=$(rel_file)" <define>"BOOST_THREAD_TEST_POST_WINDOWS_H" <dependency>$(file) <conditional>@windows-cygwin-specific <use>../build//boost_thread : $(test_name)-post_winh ] ;
}
}
@@ -363,11 +362,18 @@ rule generate_self_contained_header_tests
[ thread-run test_7571.cpp ]
[ thread-run test_9319.cpp ]
#[ thread-run test_9711.cpp ] This is an invalid use of ::then deferred.
[ thread-run test_9856.cpp ]
[ thread-run test_9856.cpp :
<toolset>gcc:<cxxflags>-fopenmp
<toolset>gcc:<linkflags>-fopenmp
]
[ thread-compile test_10963.cpp : : test_10963_c ]
[ 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 ]
;
@@ -1008,7 +1014,7 @@ rule generate_self_contained_header_tests
#[ thread-run test_10128.cpp ]
#[ thread-run test_10340.cpp ]
;
explicit ts_more_cpp11 ;
test-suite ts_more_cpp11
:
@@ -1029,13 +1035,13 @@ rule generate_self_contained_header_tests
:
[ thread-run2-noit ./experimental/parallel/v1/exception_list_pass.cpp : exception_list_p ]
;
#explicit ts_task_region ;
test-suite ts_task_region
:
[ thread-run2-noit ./experimental/parallel/v2/task_region_pass.cpp : task_region_p ]
;
explicit ts_other ;
test-suite ts_other
:
@@ -1046,7 +1052,7 @@ rule generate_self_contained_header_tests
explicit ts_ ;
test-suite ts_
:
#[ thread-run test_11256.cpp ]
#[ thread-run test_11256.cpp ]
#[ thread-run test_11256.cpp ]
#[ thread-run test_11499.cpp ]
#[ thread-run test_11611.cpp ]
@@ -1056,7 +1062,7 @@ rule generate_self_contained_header_tests
#[ thread-run test_12949.cpp ]
#[ thread-run test_13480b.cpp ]
[ thread-run test_13561.cpp ]
;
explicit test_time_jumps_1_obj ;
@@ -1095,4 +1101,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 ]
;
}
+5 -1
View File
@@ -30,12 +30,16 @@ struct wait_for_flag
flag(flag_)
{}
check_flag(check_flag const& that):
flag(that.flag)
{}
bool operator()() const
{
return flag;
}
private:
void operator=(check_flag&);
check_flag& operator=(check_flag const&);
};
+55
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();
}
+48
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();
}
@@ -14,7 +14,7 @@
#include <boost/thread/experimental/parallel/v1/exception_list.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
@@ -16,7 +16,7 @@
#include <boost/thread/experimental/parallel/v2/task_region.hpp>
#include <string>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#if ! defined BOOST_NO_CXX11_LAMBDAS && defined(BOOST_THREAD_PROVIDES_INVOKE)
using boost::experimental::parallel::v2::task_region;
+1 -1
View File
@@ -15,7 +15,7 @@
// <boost/thread/detail/invoke.hpp>
#include <boost/thread/detail/invoke.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int f()
{
@@ -16,7 +16,7 @@
// <boost/thread/detail/invoke.hpp>
#include <boost/thread/detail/invoke.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int count = 0;
@@ -15,7 +15,7 @@
// <boost/thread/detail/invoke.hpp>
#include <boost/thread/detail/invoke.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int count = 0;
@@ -15,7 +15,7 @@
// <boost/thread/detail/invoker.hpp>
#include <boost/thread/detail/invoker.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int f()
{
@@ -15,7 +15,7 @@
// <boost/thread/detail/invoker.hpp>
#include <boost/thread/detail/invoker.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int count = 0;
@@ -19,7 +19,7 @@
#endif
#include <boost/thread/detail/invoker.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int count = 0;
+13
View File
@@ -7,6 +7,7 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/shared_mutex.hpp>
@@ -38,6 +39,10 @@ public:
finish_mutex(finish_mutex_)
{}
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
locking_thread(locking_thread const&) = default;
#endif
void operator()()
{
// acquire lock
@@ -84,6 +89,10 @@ public:
unblocked_mutex(unblocked_mutex_),unblocked_count(unblocked_count_)
{}
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
simple_writing_thread(simple_writing_thread const&) = default;
#endif
void operator()()
{
boost::unique_lock<boost::shared_mutex> lk(rwm);
@@ -115,6 +124,10 @@ public:
unblocked_mutex(unblocked_mutex_),unblocked_count(unblocked_count_)
{}
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
simple_reading_thread(simple_reading_thread const&) = default;
#endif
void operator()()
{
boost::shared_lock<boost::shared_mutex> lk(rwm);
@@ -18,7 +18,7 @@
// condition_variable(const condition_variable&) = delete;
#include <boost/thread/condition_variable.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void fail()
{
@@ -18,7 +18,7 @@
// condition_variable(const condition_variable&) = delete;
#include <boost/thread/condition_variable.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
@@ -21,10 +21,10 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/locks.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
boost::condition_variable* cv;
boost::mutex m;
boost::condition_variable* g_cv;
boost::mutex g_mutex;
typedef boost::unique_lock<boost::mutex> Lock;
bool f_ready = false;
@@ -32,33 +32,33 @@ bool g_ready = false;
void f()
{
Lock lk(m);
Lock lk(g_mutex);
f_ready = true;
cv->notify_one();
cv->wait(lk);
delete cv;
g_cv->notify_one();
g_cv->wait(lk);
delete g_cv;
}
void g()
{
Lock lk(m);
Lock lk(g_mutex);
g_ready = true;
cv->notify_one();
g_cv->notify_one();
while (!f_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
cv->notify_one();
g_cv->notify_one();
}
int main()
{
cv = new boost::condition_variable;
g_cv = new boost::condition_variable;
boost::thread th2(g);
Lock lk(m);
Lock lk(g_mutex);
while (!g_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
lk.unlock();
boost::thread th1(f);
@@ -21,7 +21,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cassert>
// Summary of each test:
@@ -60,7 +60,7 @@ bool threadIsWaiting()
#ifdef BOOST_THREAD_USES_DATETIME
boost::posix_time::milliseconds posix_wait_time(1000);
boost::posix_time::milliseconds posix_wait_time(2000);
template <typename F>
void test_posix_wait_function(F f)
@@ -68,12 +68,14 @@ void test_posix_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
lk.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
boost::posix_time::ptime t0 = boost::posix_time::microsec_clock::universal_time();
flag = true;
@@ -82,7 +84,7 @@ void test_posix_wait_function(F f)
t.join();
boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::universal_time();
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -131,7 +133,7 @@ void timed_wait_relative_with_pred()
#ifdef BOOST_THREAD_USES_CHRONO
boost::chrono::milliseconds chrono_wait_time(1000);
boost::chrono::milliseconds chrono_wait_time(2000);
template <typename F>
void test_chrono_wait_function(F f)
@@ -139,12 +141,14 @@ void test_chrono_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
lk.unlock();
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
boost::chrono::steady_clock::time_point t0 = boost::chrono::steady_clock::now();
flag = true;
@@ -153,7 +157,7 @@ void test_chrono_wait_function(F f)
t.join();
boost::chrono::steady_clock::time_point t1 = boost::chrono::steady_clock::now();
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -20,7 +20,8 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
@@ -21,7 +21,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cassert>
#include "../../../timming.hpp"
@@ -20,7 +20,8 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cassert>
#include <iostream>
#include "../../../timming.hpp"
@@ -55,7 +56,7 @@ typedef boost::chrono::milliseconds milliseconds;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
BOOST_ATTRIBUTE_UNUSED const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
@@ -64,9 +65,11 @@ void f()
assert(test2 == 0);
test1 = 1;
cv.notify_one();
Clock::time_point t0 = Clock::now();
BOOST_ATTRIBUTE_UNUSED Clock::time_point t0 = Clock::now();
cv.wait_for(lk, milliseconds(250), Pred(test2));
Clock::time_point t1 = Clock::now();
BOOST_ATTRIBUTE_UNUSED Clock::time_point t1 = Clock::now();
(void)t0;
(void)t1;
if (runs == 0)
{
assert(t1 - t0 < max_diff);
@@ -21,7 +21,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cassert>
#include <iostream>
@@ -20,7 +20,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <cassert>
#include "../../../timming.hpp"
@@ -20,7 +20,8 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cassert>
#include <iostream>
#include "../../../timming.hpp"
@@ -79,8 +80,9 @@ void f()
cv.notify_one();
Clock::time_point t0 = Clock::now();
Clock::time_point t = t0 + Clock::duration(250);
bool r = cv.wait_until(lk, t, Pred(test2));
BOOST_ATTRIBUTE_UNUSED bool r = cv.wait_until(lk, t, Pred(test2));
Clock::time_point t1 = Clock::now();
(void)r;
if (runs == 0)
{
assert(t1 - t0 < max_diff);
@@ -18,7 +18,7 @@
// condition_variable_any(const condition_variable_any&) = delete;
#include <boost/thread/condition_variable.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void fail()
{
@@ -18,7 +18,7 @@
// condition_variable_any(const condition_variable_any&) = delete;
#include <boost/thread/condition_variable.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
@@ -21,10 +21,10 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/locks.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
boost::condition_variable_any* cv;
boost::timed_mutex m;
boost::condition_variable_any* g_cv;
boost::timed_mutex g_mutex;
typedef boost::unique_lock<boost::timed_mutex> Lock;
bool f_ready = false;
@@ -32,33 +32,33 @@ bool g_ready = false;
void f()
{
Lock lk(m);
Lock lk(g_mutex);
f_ready = true;
cv->notify_one();
cv->wait(lk);
delete cv;
g_cv->notify_one();
g_cv->wait(lk);
delete g_cv;
}
void g()
{
Lock lk(m);
Lock lk(g_mutex);
g_ready = true;
cv->notify_one();
g_cv->notify_one();
while (!f_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
cv->notify_one();
g_cv->notify_one();
}
int main()
{
cv = new boost::condition_variable_any;
g_cv = new boost::condition_variable_any;
boost::thread th2(g);
Lock lk(m);
Lock lk(g_mutex);
while (!g_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
lk.unlock();
boost::thread th1(f);
@@ -21,7 +21,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cassert>
// Summary of each test:
@@ -60,7 +60,7 @@ bool threadIsWaiting()
#ifdef BOOST_THREAD_USES_DATETIME
boost::posix_time::milliseconds posix_wait_time(1000);
boost::posix_time::milliseconds posix_wait_time(2000);
template <typename F>
void test_posix_wait_function(F f)
@@ -68,12 +68,14 @@ void test_posix_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
lk.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
boost::posix_time::ptime t0 = boost::posix_time::microsec_clock::universal_time();
flag = true;
@@ -82,7 +84,7 @@ void test_posix_wait_function(F f)
t.join();
boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::universal_time();
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -131,7 +133,7 @@ void timed_wait_relative_with_pred()
#ifdef BOOST_THREAD_USES_CHRONO
boost::chrono::milliseconds chrono_wait_time(1000);
boost::chrono::milliseconds chrono_wait_time(2000);
template <typename F>
void test_chrono_wait_function(F f)
@@ -139,12 +141,14 @@ void test_chrono_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
lk.unlock();
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
boost::chrono::steady_clock::time_point t0 = boost::chrono::steady_clock::now();
flag = true;
@@ -153,7 +157,7 @@ void test_chrono_wait_function(F f)
t.join();
boost::chrono::steady_clock::time_point t1 = boost::chrono::steady_clock::now();
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -20,7 +20,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include "../../../timming.hpp"
#if defined BOOST_THREAD_USES_CHRONO
@@ -20,7 +20,7 @@
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include "../../../timming.hpp"
#if defined BOOST_THREAD_USES_CHRONO

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