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

Compare commits

...

1831 Commits

Author SHA1 Message Date
Vicente J. Botet Escriba
748fdee203 #130 - Bug in boost::condition_variable on Windows. 2017-08-28 22:07:02 +02:00
Vicente J. Botet Escriba
db6de8fd42 #130 - Bug in boost::condition_variable on Windows. 2017-08-28 22:06:53 +02:00
Vicente J. Botet Escriba
32229388f5 make use of timespec_now_realtime to fix issues with timespec_now. 2017-08-16 23:14:06 +02:00
Vicente J. Botet Escriba
333365aefe Merge branch 'develop' 2017-06-11 11:33:12 +02:00
Vicente J. Botet Escriba
d4cff01c72 #12519. 2017-06-11 11:30:59 +02:00
Vicente J. Botet Escriba
5f7dc381c7 Merge pull request #125 from vslavik/fix-comparison
Don't compare shared_ptr<> to 0
2017-06-07 17:57:21 +02:00
Václav Slavík
ea0bc01400 Don't compare shared_ptr<> to 0
Update the code to consistently use a check for .get() == 0, as was
already done in most, but not all, places, to avoid issues with
ambiguous overloaded operator== and operator!=.
2017-06-07 17:24:40 +02:00
Vicente J. Botet Escriba
3bc883d114 Merge pull request #124 from florianbehrens/patch-1
Fixed future::then template argument in documentation.
2017-05-24 12:18:21 +02:00
Florian Behrens
2e2850ff94 Fixed future::then template argument in documentation. 2017-05-24 12:03:38 +02:00
Vicente J. Botet Escriba
1a8019f499 Merge pull request #123 from Lastique/fix_entry_manager
Fix entry_manager constructor not accepting entry_ptr rvalue
2017-05-23 21:54:30 +02:00
Andrey Semashev
bf4b38b0af Fixed entry_manager constructor not accepting entry_ptr rvalue. This resolves compilation failures with MinGW. 2017-05-22 13:11:11 +03:00
Vicente J. Botet Escriba
f78b10a450 Merge pull request #122 from vincenthsu/develop
Fix sync_bounded_queue<>::size()
2017-05-11 01:33:43 +02:00
Vincent Hsu
603689372c Fix sync_bounded_queue<>::size() 2017-05-10 13:12:01 +08:00
Vicente J. Botet Escriba
5b05d6a8c8 fix compile error. 2017-05-07 16:01:10 +02:00
Vicente J. Botet Escriba
12c0fe14cd fix compile error. 2017-05-07 09:05:12 +02:00
Vicente J. Botet Escriba
ace2b8f89e rollback and use RAII. 2017-05-06 23:04:52 +02:00
Vicente J. Botet Escriba
24188f295c fix missing remove aiter while return. 2017-05-06 22:53:41 +02:00
Vicente J. Botet Escriba
653671bc0e fix compilation error. 2017-05-06 14:43:49 +02:00
Vicente J. Botet Escriba
c251497758 Avoid throwing on destructor: condition_variable. 2017-05-06 12:09:23 +02:00
Vicente J. Botet Escriba
69435fa44e try to fix lock on destructor issues. 2017-05-06 03:58:13 +02:00
Vicente J. Botet Escriba
6bc6fcab9a fix compilation error :( 2017-05-04 19:16:04 +02:00
Vicente J. Botet Escriba
50bac8c0eb fix compilation error :( 2017-05-04 07:58:58 +02:00
Vicente J. Botet Escriba
d709d4707c comment failing test. It is surely a bad test. 2017-05-01 03:39:53 +02:00
Vicente J. Botet Escriba
879db6841d try to fix compilation error on windows condition_variable.hpp. 2017-05-01 02:58:45 +02:00
Vicente J. Botet Escriba
2ce385b949 Add missing iostream. 2017-04-29 18:19:02 +02:00
Vicente J. Botet Escriba
21458fcc67 Add missing iostream. 2017-04-29 17:56:32 +02:00
Vicente J. Botet Escriba
d83b7ddc0f Merge branch 'develop' of github.com:boostorg/thread into develop 2017-04-29 17:35:01 +02:00
Vicente J. Botet Escriba
5ee3e8d04b manage with #12888. 2017-04-29 16:17:07 +02:00
Vicente J. Botet Escriba
dcafe1e17d Add noexcept(false) in destructor that could throw in C++11. 2017-04-29 16:15:57 +02:00
Vicente J. Botet Escriba
8dfa7c2e42 fix issue throw() noexcept issue. 2017-04-29 16:14:41 +02:00
Vicente J. Botet Escriba
c83d30f526 manage with #12874. 2017-04-29 16:13:52 +02:00
Vicente J. Botet Escriba
51b367df53 manage with 12958. 2017-04-29 16:12:35 +02:00
Vicente J. Botet Escriba
da83662e1a added test for 12949. 2017-04-29 16:11:31 +02:00
Vicente J. Botet Escriba
36861e5b67 Comment error. Need to be fixed. 2017-04-29 16:10:43 +02:00
Vicente J. Botet Escriba
67df4dd84e Merge pull request #120 from MarcelRaad/patch-2
Remove wrong MSVC version check
2017-04-21 02:10:19 +02:00
Marcel Raad
676521808d Remove wrong MSVC version check
There is no compiler with (_MSC_VER > 2000) and taking the legacy codepath would probably break compilation again when there is. As (_MSC_VER < 1300) (that would be MSVC up to 6.0 from 1998) is not supported by Boost anymore anyway and cannot compile Boost.Thread, this codepath can just be removed completely.
2017-03-24 22:28:41 +01:00
Vicente J. Botet Escriba
5363e099e4 Merge branch 'develop' 2017-03-03 07:28:59 +01:00
Vicente J. Botet Escriba
65f98979ff replace and by && to make the code portable 2017-03-01 19:39:56 +01:00
Vicente J. Botet Escriba
496acc1161 disable some tests with C++98. 2017-02-28 23:29:28 +01:00
Vicente J. Botet Escriba
30dff7f84a try to fix MONOTONIC timming issue. 2017-02-28 23:28:44 +01:00
Vicente J. Botet Escriba
7cb5d5bb46 Merge pull request #118 from Oberon00/loop-executor-no-polling
Loop executor: Don't poll but wait in loop() + test enhanchment.
2017-02-28 19:55:10 +01:00
Christian Neumüller
74c98b7fab loop_executor: (Re)activate and enhanche test. 2017-02-28 18:50:09 +01:00
Christian Neumüller
2ed0c2ad5f Loop executor: Don't poll but wait in loop(). 2017-02-28 18:50:08 +01:00
Vicente J. Botet Escriba
c969a6cf9c Fix uninitialized variables in scoped thread examples. Disable detach example for clang std::thread, it crashes. 2017-02-28 08:22:15 +01:00
Vicente J. Botet Escriba
c7348b29cf Compile conditionally to try to fix the timespec monotonic issue. This is not a final solution as we need to add two defines while building Boost.Thread, but atleast will allow to check if the solution work. 2017-02-25 22:41:00 +01:00
Vicente J. Botet Escriba
f79d51f099 Merge branch 'develop' 2017-02-25 13:57:19 +01:00
Vicente J. Botet Escriba
0d850b47ab Merge branch 'develop' of github.com:boostorg/thread into develop 2017-02-24 15:21:19 +01:00
Vicente J. Botet Escriba
9bbf9bed80 rollback MONOTONIC_CLOCK change as it seems it introduce regressions. 2017-02-24 15:20:04 +01:00
Vicente J. Botet Escriba
aadf0acce3 Merge pull request #114 from aargor/develop
Update MSC version check for VS2017RTW
2017-02-24 15:08:13 +01:00
Aaron Gorenstein
bd0379af57 Update MSC version check for VS2017RTW 2017-02-21 13:35:44 -08:00
Vicente J. Botet Escriba
336259c36a Merge branch 'develop' 2017-02-19 11:27:10 +01:00
Vicente J. Botet Escriba
544eda51bd make use of MONOTONIC_CLOCK when available. 2017-02-18 10:34:36 +01:00
Vicente J. Botet Escriba
e16705a72a Added more functors to scoped threads. 2017-02-18 10:22:34 +01:00
Vicente J. Botet Escriba
61a26492c3 use SFINAE for wait_for_all is_future_type. 2017-02-18 10:21:45 +01:00
Vicente J. Botet Escriba
854c61f597 Added Thread parameter in scoped_thread and thread_guard classes. 2017-01-25 13:20:08 +01:00
Vicente J. Botet Escriba
4d4ddcdc36 Merge branch 'develop' of github.com:boostorg/thread into develop 2017-01-25 08:13:22 +01:00
Vicente J. Botet Escriba
9347d9b731 Added Thread parameter in scoped_thread and thread_guard classes. 2017-01-25 08:13:04 +01:00
Vicente J. Botet Escriba
0a4733c9ad Merge pull request #110 from Lastique/fix_mingw
Compilation fixes for MinGW. Support for MSVC on ARM.
2017-01-22 10:19:54 +01:00
Andrey Semashev
b96d05461f Compilation fixes for MinGW. Support for MSVC on ARM.
1. Apparently, some versions of MinGW declare interlocked intrinsics
without volatile qualifiers. To avoid compilation failures cast away
volatile from pointers. This should also work with qualified pointers as
well.

2. Changed interlocked read/write helpers for MSVC. VS2012 and later have
the option to change volatile behavior to the standard C++. In that mode,
volatile no longer enforces memory ordering. To ensure the correct
behavior of the helpers, use compiler barriers to prohibit code
reordering. Also, limit the version to x86 only.

3. Added a separate version of interlocked read/write helpers for MSVC on
ARM. To avoid dependency on the compiler switch, use intrinsics to load
and store values and also emit the hardware memory fence.

4. Added two versions of interlocked read/write helpers for gcc and
compatible compilers. One version is based on __atomic intrinsics, the
other one (for older versions) uses inline assembler. These versions
should be more optimal than the generic fallback.
2017-01-07 20:08:30 +03:00
Vicente J. Botet Escriba
41f19bb098 Merge pull request #109 from jhunold/extra_semi
Remove trailing ";"
2017-01-06 20:58:30 +01:00
Jürgen Hunold
050a45aaa4 Remove trailing ";"
clang warning: extra ';' after member function definition [-Wextra-semi]
2017-01-06 10:01:37 +01:00
Vicente J. Botet Escriba
23cff22e5a fix category in thread_excaption. 2017-01-02 01:21:02 +01:00
Vicente J. Botet Escriba
a75995475a Merge pull request #107 from equal-l2/patch-1
fix typo
2016-12-19 23:54:49 +01:00
equal-l2
3ac5fd0916 fix typo
Just in case
2016-12-20 06:27:06 +09:00
Vicente J. Botet Escriba
56bce64d32 Merge pull request #106 from apolukhin/doc_clarify
Less ambiguous definition for lock(...) functions
2016-12-08 18:56:38 +01:00
Antony Polukhin
4385984215 Less ambiguous definition for lock(...) functions 2016-12-04 02:55:02 +03:00
Vicente J. Botet Escriba
3391bf87c6 Merge branch 'master' of github.com:boostorg/thread 2016-11-06 16:16:03 +01:00
Vicente J. Botet Escriba
bc6b31e1f7 Merge branch 'develop' 2016-11-05 23:39:19 +01:00
Vicente J. Botet Escriba
425b9924f0 Update README.md 2016-11-05 23:37:45 +01:00
Vicente J. Botet Escriba
84720b7664 Merge branch 'develop' 2016-11-05 00:31:01 +01:00
Vicente J. Botet Escriba
1309e9aa4b version 4.7.2. 2016-11-04 00:57:41 +01:00
Vicente J. Botet Escriba
50a926e973 update doc 1.63. 2016-11-04 00:56:37 +01:00
Vicente J. Botet Escriba
a0bda34054 fix typo in merge. 2016-11-04 00:52:59 +01:00
Vicente J. Botet Escriba
3a9a296e55 Merge pull request #105 from apolukhin/fixing_lost_notify
Fix minor possibility of loosing the notify
2016-11-03 08:06:34 +01:00
Antony Polukhin
184d7504b7 Fix minor possibility of loosing the notify 2016-11-02 23:13:26 +03:00
Vicente J. Botet Escriba
2f8b5794b7 Merge pull request #104 from rick68/patch-9
fix compile failed with boost::user_scheduler
2016-10-24 09:10:36 +02:00
Wei-Ming Yang
7e7d3bf1a7 fix compile failed with boost::user_scheduler
The `work` is not in namespace `boost::thread_detail` anymore.
2016-10-24 08:24:25 +08:00
Vicente J. Botet Escriba
f8b76aa907 Merge pull request #103 from rick68/patch-8
fix relational operators of boost::synchronized_value<>
2016-10-22 23:47:09 +02:00
Vicente J. Botet Escriba
7eeae5b265 Merge pull request #102 from rick68/patch-7
fix boost::synchronized_value<>::load()
2016-10-22 12:30:40 +02:00
Wei-Ming Yang
e71f52f9ed fix relational operators of boost::synchronized_value<>
fix incorrect relational operators.
2016-10-22 17:53:10 +08:00
Wei-Ming Yang
cd41de6e3f fix boost::synchronized_value<>::load()
The data member `boost::synchronized_value<>::value_` is not mutable, so boost::synchronized_value<>::load() could not be const.
2016-10-22 17:18:28 +08:00
Rene Rivera
7879a4c286 Add, and update, documentation build targets. 2016-10-10 11:39:53 -05:00
Rene Rivera
c70647988d Add, and update, documentation build targets. 2016-10-07 23:07:36 -05:00
Vicente J. Botet Escriba
11f18980ca Merge branch 'develop' 2016-09-06 20:11:30 +02:00
Vicente J. Botet Escriba
866ff746ae fix queue_back/front_view: documentation mismatch 2016-09-06 20:10:50 +02:00
Vicente J. Botet Escriba
12e2c8aaca Merge branch 'develop' 2016-09-06 18:50:21 +02:00
Vicente J. Botet Escriba
807f429e17 update history. 2016-09-06 18:49:57 +02:00
Vicente J. Botet Escriba
046d716bbf Merge branch 'develop' 2016-09-03 21:17:42 +02:00
Vicente J. Botet Escriba
5450e98c6b Use BOOST_THREAD_ASYNC_FUTURE_WAITS instead of BOOST_THREAD_FUTURE_BLOCKING and wait instead of join. See #11851 and #12220. 2016-09-03 17:18:53 +02:00
Vicente J. Botet Escriba
5b9c1fad85 Merge branch 'develop' 2016-09-02 07:27:09 +02:00
Vicente J. Botet Escriba
c52a34c2cf format. 2016-09-01 07:41:20 +02:00
Vicente J. Botet Escriba
fc748dbddf 12293- make the unwrap constructor explicit. 2016-08-20 09:27:47 +02:00
Vicente J. Botet Escriba
58c6b384cc Merge branch 'develop' 2016-08-16 23:02:52 +02:00
Vicente J. Botet Escriba
e34d343c12 avoid to unlock the mutext befote release_waiters. 2016-08-15 22:50:23 +02:00
Vicente J. Botet Escriba
7c1570328e Merge branch 'develop' 2016-08-15 11:54:35 +02:00
Vicente J. Botet Escriba
eeb24a6a6a Merge branch 'develop' of github.com:boostorg/thread into develop 2016-08-10 07:48:35 +02:00
Vicente J. Botet Escriba
25b2062881 update history and version. 2016-08-10 07:48:25 +02:00
Vicente J. Botet Escriba
9d33a59542 Merge pull request #92 from Lastique/fix_msvc8_compilation
Fixed compilation with MSVC-8.
2016-08-10 07:43:37 +02:00
Vicente J. Botet Escriba
41f93eb513 Add test for 12293. 2016-08-09 02:49:23 +02:00
Vicente J. Botet Escriba
63484911c6 fix compile error when INTERRUPTIONS are not provided. 2016-08-09 02:48:26 +02:00
Vicente J. Botet Escriba
bb2c38aa61 Fix result_of signature and unlonk before notyfying. 2016-08-09 02:47:22 +02:00
Vicente J. Botet Escriba
8cf36f18cc rename make_exceptional to make exceptional_future. 2016-08-09 02:46:00 +02:00
Vicente J. Botet Escriba
97895e410f merge from develop. 2016-08-09 01:14:41 +02:00
Vicente J. Botet Escriba
7ffdc5e10a Merge pull request #90 from rick68/patch-3
fix a bug in try_lock_wrapper<>::operator=()
2016-08-07 13:05:40 +02:00
Vicente J. Botet Escriba
25864ce33a Merge pull request #93 from vslavik/fix-shadowing-warnings
Fix variable shadowing warnings (Clang)
2016-08-07 13:04:09 +02:00
Vicente J. Botet Escriba
f0c50a00c0 Merge pull request #96 from zonr/develop
rename async_func.hpp to invoker.hpp.
2016-08-07 13:01:38 +02:00
Vicente J. Botet Escriba
b511472614 Merge pull request #95 from rick68/patch-5
fix a mistake in boost::completion_latch
2016-08-07 13:00:31 +02:00
Vicente J. Botet Escriba
13c15cd002 Merge pull request #97 from rick68/patch-6
fix a mistake in sync_timed_queue<>::pull_until()
2016-08-07 12:58:22 +02:00
Vicente J. Botet Escriba
1296bf4de9 Merge pull request #91 from Lastique/patch-6
Add shared_lock_guard to the included lock types
2016-08-07 12:57:09 +02:00
Wei-Ming Yang
9c80dd207e fix a mistake in sync_timed_queue<>::pull_until()
The type of `super::not_empty_` in `sync_timed_queue<>` is `boost::condition_variable`, and the return type of `wait_until()` is `boost::cv_status`.
2016-07-31 12:12:55 +08:00
Zonr Chang
0f2fed0577 rename async_func.hpp to invoker.hpp.
This removes vestiges of commit 1d7da085.
2016-07-26 16:07:29 +08:00
Wei-Ming Yang
96390e1b46 fix a mistake in boost::completion_latch
The constructor `completion_latch(std::size_t count, void(*funct)())` does not use any template arguments.
2016-07-26 07:39:10 +08:00
Václav Slavík
e2ff1e4c67 Fix variable shadowing warnings (Clang)
Fix multiple instance of declarations shadowing either local variables
or fields.
2016-07-24 22:03:07 +02:00
Andrey Semashev
49ab2e8619 Fixed compilation with MSVC-8.
Make sure _WIN32_WINNT is defined when windows.h is included. This is
achieved by (a) making sure boost/detail/winapi/config.hpp is included
before any other headers and (b) BOOST_USE_WINDOWS_H is defined so that
the header defines _WIN32_WINNT based on the default target Windows
version. This ensures that all APIs used by the implementation are
available.

Also extracted WIN32_LEAN_AND_MEAN definition to the Jamfile so that it is
consistently defined for all translation units instead of only tss*.cpp.
2016-07-16 19:50:46 +03:00
Andrey Semashev
96b96b4e42 Add shared_lock_guard to the included lock types 2016-07-13 14:42:06 +04:00
Wei-Ming Yang
a774cac3f2 fix a bug in try_lock_wrapper<>::operator=()
It invokes the copy constructor that already be deleted.
2016-07-13 15:34:01 +08:00
Vicente J. Botet Escriba
6ec16408fc Merge pull request #89 from rick68/patch-2
fix a bug in upgrade_to_unique_lock<>::operator=()
2016-07-13 07:00:39 +02:00
Wei-Ming Yang
850f3eced3 fix a bug in upgrade_to_unique_lock<>::operator=()
It invokes the copy constructor that already be deleted.
2016-07-13 12:42:20 +08:00
Vicente J. Botet Escriba
fde2e061f5 Merge pull request #88 from rick68/patch-1
fix typos in boost::upgrade_lock
2016-07-11 22:45:18 +02:00
Wei-Ming Yang
e5c086cef4 fix typos in boost::upgrade_lock
Corrects the class name in exception messages.
2016-07-12 01:17:41 +08:00
Vladimir Prus
0b5e4f88b5 Support "b2 install". 2016-07-08 15:12:17 +03:00
Vicente J. Botet Escriba
8d150587fa Merge pull request #87 from timblechmann/feature/msvc-2015
win32: compile fix for msvc2015
2016-06-28 14:19:10 +02:00
Tim Blechmann
206ff0ba7c win32: compile fix for msvc2015 2016-06-20 11:11:17 +02:00
Vicente J. Botet Escriba
0ef1b1b760 Merge pull request #83 from v4hn/spell-out-thread-ns
specify boost:: prefix for future threads
2016-05-26 07:39:30 +02:00
Michael Görner
ab9f931bce specify boost:: prefix for future threads
This makes the usage of the boost::thread class consistent within the header
2016-05-26 01:18:16 +02:00
Vicente J. Botet Escriba
21b084384c Merge pull request #86 from MarcelRaad/windows_version
Fix Windows version problems
2016-05-25 23:26:16 +02:00
Marcel Raad
ccca616330 Fix Windows version problems
- the target Windows version was hardcoded to Windows 95
  in thread.cpp if not already defined
- the include for BOOST_USE_WINAPI_VERSION was missing
2016-05-25 15:54:28 +02:00
Vicente J. Botet Escriba
2494f3fc7a Apply manualy fixes on develop concerning memory leak os tss and scoped_thread move assignement. 2016-04-24 01:05:45 +02:00
Vicente J. Botet Escriba
2c3acef281 remove unuseful files. 2016-04-21 19:11:55 +02:00
Vicente J. Botet Escriba
587ad42548 fix hiden rename 2016-04-21 00:10:30 +02:00
Vicente J. Botet Escriba
ef401d81db Merge branch 'develop' of github.com:boostorg/thread into develop 2016-04-20 23:59:40 +02:00
Vicente J. Botet Escriba
57f34e1ea4 fix memory leak. 2016-04-20 23:52:30 +02:00
Vicente J. Botet Escriba
daae305bf7 fix memory leak. 2016-04-20 23:50:43 +02:00
Vicente J. Botet Escriba
55a1325f30 call interrupt only if joinable. 2016-04-20 23:50:16 +02:00
Vicente J. Botet Escriba
46f0be2dce Describe what happens on thread::interrupt with a non-a-thread. 2016-04-20 23:49:46 +02:00
Vicente J. Botet Escriba
98dbc9da41 Merge pull request #81 from blastrock/develop
fix crash in regression tests because of tls
2016-04-20 23:40:54 +02:00
Vicente J. Botet Escriba
640e1acb98 Merge pull request #78 from brycelelbach/patch-1
Fix typo in implementation detail namespace
2016-04-20 23:20:19 +02:00
Vicente J. Botet Escriba
7f2535015d Merge pull request #82 from akrzemi1/patch-1
docs: thread_interruption never calls terminate()
2016-04-20 23:19:05 +02:00
Vicente J. Botet Escriba
aab2891cdb fix scoped_thread move assignement description. 2016-04-20 23:12:55 +02:00
Andrzej Krzemieński
8bbe005bbc docs: thread_interruption never calls terminate()
This note in the docs tries to clarify that exception `thread_interrupted` leaving the thread-main function never triggers a call to `std::terminate`. The previous wording used word 'terminate' in a way that made the semantics ambiguous.
2016-04-20 09:10:10 +02:00
Philippe Daouadi
db5898ba46 fix crash in regression tests because of tls 2016-04-18 10:23:23 +02:00
Vicente J. Botet Escriba
c7a5122fd3 Merge branch 'develop' of github.com:boostorg/thread into develop 2016-04-17 23:59:52 +02:00
Vicente J. Botet Escriba
b932b8c015 Merge pull request #80 from blastrock/develop
Fix leak in tls
2016-04-17 23:59:29 +02:00
Vicente J. Botet Escriba
411798367b call on_desctruction on scoped_thread move assignment. 2016-04-17 23:41:21 +02:00
Philippe Daouadi
e29a4129e8 fix leak in tls 2016-04-16 10:48:40 +02:00
Vicente J. Botet Escriba
159868ac77 Merge branch 'develop' 2016-04-01 00:27:18 +02:00
Vicente J. Botet Escriba
f6febf8dfc update las changes in history. 2016-04-01 00:26:58 +02:00
Vicente J. Botet Escriba
f65e89a85a Merge branch 'develop' 2016-04-01 00:20:44 +02:00
Vicente J. Botet Escriba
2fd8a8dd55 update las changes in history. 2016-04-01 00:20:10 +02:00
Vicente J. Botet Escriba
bb47c16939 Merge branch 'develop' 2016-03-28 23:12:48 +02:00
Vicente J. Botet Escriba
9db70b803d add missing template parameter in wait_until. 2016-03-25 00:02:04 +01:00
Vicente J. Botet Escriba
47357de276 rollback BOOST_THREAD_PATCH. 2016-03-23 23:15:50 +01:00
Vicente J. Botet Escriba
02fd2d041b Merge branch 'develop' 2016-03-08 07:55:45 +01:00
Vicente J. Botet Escriba
382ac5a426 update release notes. 2016-03-05 11:13:41 +01:00
Vicente J. Botet Escriba
317a735836 try to manage with #12036. 2016-03-05 11:07:54 +01:00
Vicente J. Botet Escriba
ae22c68ab7 fix #11494. 2016-03-05 10:43:33 +01:00
Vicente J. Botet Escriba
4fb88b29fa take in account error in condition_variable_any::wait_until. 2016-02-28 23:49:29 +01:00
Vicente J. Botet Escriba
2661c06698 Merge branch 'develop' 2016-02-28 19:30:15 +01:00
Vicente J. Botet Escriba
a45f36cbc6 Take in account possible issue while initializing cout. #12013 2016-02-28 19:26:38 +01:00
Vicente J. Botet Escriba
5fba7f88a6 Merge branch 'develop' of github.com:boostorg/thread into develop 2016-02-28 19:24:43 +01:00
Vicente J. Botet Escriba
ad7b36dd34 Merge pull request #79 from Lastique/patch-5
Fix compilation on Windows
2016-02-27 22:28:44 +01:00
Andrey Semashev
408d82ded9 Fixed compilation on Windows
Add a missing include for get_milliseconds_until and namespace qualification.
2016-02-27 21:48:23 +03:00
Bryce Adelstein-Lelbach
3f5c0bfb6c Fix typo in implementation detail namespace
Either I'm missing something or hidden has been misspelled as 'hiden' here.
2016-02-19 10:00:25 -08:00
Vicente J. Botet Escriba
8a5cf38a3c Merge pull request #76 from zerotypos-found/fix_typo
Fix typo in doc: a -> an, an -> a
2016-02-05 08:30:51 +01:00
Vicente J. Botet Escriba
0ddc3d40fa Merge pull request #77 from Bklyn/doc-fix
Fix some typos
2016-02-05 08:29:13 +01:00
Caleb Epstein
565c8e0bb8 Fix some typos 2016-02-04 16:03:37 -05:00
zerotypos-found
6954e6ca64 Fix typo in doc: a -> an, an -> a. 2015-12-22 13:19:09 +09:00
Vicente J. Botet Escriba
568275dc5f Merge branch 'feature/add_launch_sync_policy' into develop 2015-12-20 15:36:48 +01:00
Vicente J. Botet Escriba
1d04db8887 Merge branch 'develop' into feature/add_launch_sync_policy 2015-12-19 23:07:04 +01:00
Vicente J. Botet Escriba
83f877a238 Merge branch 'develop' 2015-12-08 06:30:55 +01:00
Vicente J. Botet Escriba
7beae6ac06 Merge pull request #75 from zerotypos-found/fix_typo
Fix doc typo
2015-12-08 06:29:12 +01:00
zerotypos-found
dc078f0394 Fix doc typo. 2015-12-08 12:57:28 +09:00
Vicente J. Botet Escriba
47f615d073 Merge branch 'develop' 2015-12-07 22:04:51 +01:00
Vicente J. Botet Escriba
6374e09021 update fixes. 2015-12-06 10:27:32 +01:00
Vicente J. Botet Escriba
9f55587ab0 add missing detach in thread assignment V2. #11796. 2015-12-05 14:49:13 +01:00
Vicente J. Botet Escriba
7079a80edf Merge branch 'develop' 2015-11-24 23:03:35 +01:00
Vicente J. Botet Escriba
674e1304ef take care of #11818. deferred continuations should not wait too soon. 2015-11-24 22:58:08 +01:00
Vicente J. Botet Escriba
4ad37504ee #11817. missing include file. 2015-11-24 06:50:08 +01:00
Vicente J. Botet Escriba
29849ca3ec manage with bad destructor version documentation. #11795. 2015-11-16 23:16:45 +01:00
Vicente J. Botet Escriba
a636c8d605 Merge branch 'develop' into feature/add_launch_sync_policy 2015-11-15 00:07:51 +01:00
Vicente J. Botet Escriba
dbf28a4ac4 Merge branch 'develop' 2015-11-15 00:02:15 +01:00
Vicente J. Botet Escriba
dbf0160b1e uncomment previous failing fallback_to test. 2015-11-14 12:38:37 +01:00
Vicente J. Botet Escriba
60a8cb9b5c Merge pull request #74 from tvbuehler/fix-future-resource-leak
fix increasing memory usage / unjoined threads in .then()
2015-11-14 08:37:25 +01:00
Stefan Bühler
8cba434c59 neither continuation nor parent need mutex protection 2015-11-13 12:18:38 +01:00
Stefan Bühler
feab8add3f refactor deferred execute calls 2015-11-13 12:18:38 +01:00
Stefan Bühler
f36857ffef explicitly clear continuation parent state 2015-11-13 12:18:38 +01:00
Stefan Bühler
4ba8415b08 drop sentinel in continuation/unwrap states
- instead keep the inner state alive in places where we move ourself after we
  locked the inner state
2015-11-13 12:18:34 +01:00
Vicente J. Botet Escriba
aa608685af rename centinel by sentinel. reset it as soon as the non deferred continuation is launched so that resources are released. 2015-11-11 00:31:59 +01:00
Vicente J. Botet Escriba
ba43e202c3 add implicit unwrap test. 2015-11-11 00:29:15 +01:00
Vicente J. Botet Escriba
3edbf67ef0 add unwrap/wait/get test. 2015-11-10 07:40:31 +01:00
Vicente J. Botet Escriba
7b67789f98 Avoid ambiguity with C++17 std::invoke. 2015-11-09 23:58:15 +01:00
Vicente J. Botet Escriba
3f7f34b634 minor cleanup on condition_variable. 2015-11-08 17:30:29 +01:00
Vicente J. Botet Escriba
c0fe04ecc9 ensure the void* in the cleanup is shared during the call. 2015-11-08 11:04:40 +01:00
Vicente J. Botet Escriba
eb6d819218 remove unused typedef. 2015-11-08 10:58:36 +01:00
Vicente J. Botet Escriba
578bb1b3ed Merge pull request #72 from ya1gaurav/patch-2
Remove duplicate conditional check.
2015-11-06 19:35:44 +01:00
Gaurav
40b3dc0c2c Remove duplicate conditional check.
thread_info already checked against Null at line no 86, no need to check again.
2015-11-03 14:28:37 +05:30
Vicente J. Botet Escriba
55536c3e23 first commit for launch::sync policy. 2015-10-29 17:22:32 +01:00
Vicente J. Botet Escriba
2866734b15 Merge branch 'develop' 2015-10-29 11:33:17 +01:00
Vicente J. Botet Escriba
c0317c5206 Add return *this in invoker assignment. 2015-10-29 11:06:48 +01:00
Vicente J. Botet Escriba
06d2571ec6 Merge branch 'master' into develop 2015-10-22 23:05:13 +02:00
Vicente J. Botet Escriba
fdaba4efe7 try to fix Windows issue with system::time_point arithmetic. 2015-10-22 23:04:23 +02:00
Vicente J. Botet Escriba
8a7cd83123 Merge branch 'develop' 2015-10-22 11:22:27 +02:00
Vicente J. Botet Escriba
98a5e343f8 fix compiler error on time_point_cast. 2015-10-22 11:15:20 +02:00
Vicente J. Botet Escriba
89d8e18c82 Merge branch 'develop' 2015-10-22 00:43:17 +02:00
Vicente J. Botet Escriba
d9492530bd fix timi_point conversion. 2015-10-21 20:19:56 +02:00
Vicente J. Botet Escriba
f6c732b124 Merge branch 'develop' 2015-10-21 18:59:44 +02:00
Vicente J. Botet Escriba
dcc3227668 don't use steady clock if not supported. 2015-10-20 10:03:51 +02:00
Vicente J. Botet Escriba
b3d237731a avoid Boost.Test. 2015-10-20 10:03:15 +02:00
Vicente J. Botet Escriba
4321b59c1e Merge branch 'develop' 2015-10-20 00:23:51 +02:00
Vicente J. Botet Escriba
67759325eb update version 2015-10-20 00:23:06 +02:00
Vicente J. Botet Escriba
8153e2a652 try to fix MSVC issue with template class. 2015-10-19 20:01:42 +02:00
Vicente J. Botet Escriba
7876163c68 make sync optional. 2015-10-19 00:50:29 +02:00
Vicente J. Botet Escriba
805fa41a4e try to fix issues with gcc-3.x.y with not supported -Wno-variadic-macros. 2015-10-18 18:50:34 +02:00
Vicente J. Botet Escriba
0e6376d93a make async return a blocking future. 2015-10-18 18:47:24 +02:00
Vicente J. Botet Escriba
bf1fc5158e Added launch::inherit and specialize the behavior for the(launch::inherit, Cont). 2015-10-18 04:17:27 +02:00
Vicente J. Botet Escriba
1e4e9ab84c #11734. future::then(Cont) should be able to execute the contination on undetermined thread. 2015-10-18 00:36:25 +02:00
Vicente J. Botet Escriba
88ab663ac5 Merge branch 'feature/non_blocking_futures' into develop 2015-10-17 14:57:39 +02:00
Vicente J. Botet Escriba
0ab63b9248 Remove counting when async future blocking. 2015-10-17 11:38:06 +02:00
Vicente J. Botet Escriba
73053e4abe merge from develop. 2015-10-17 10:51:50 +02:00
Vicente J. Botet Escriba
9a4fbbec5d Merge branch 'develop' 2015-10-17 08:22:38 +02:00
Vicente J. Botet Escriba
b4744a2aa8 then can be now sync. The destructor of a shared state that joins check for thread_ifbefore join. Adde continuation_shared_state to share common behavior. 2015-10-17 00:44:45 +02:00
Vicente J. Botet Escriba
4169bcee44 Addoverloadsfor shared. 2015-10-17 00:40:53 +02:00
Vicente J. Botet Escriba
baf516e82f comment serial conttest. 2015-10-17 00:40:23 +02:00
Vicente J. Botet Escriba
cc309eef8d refactor ::then(f) in function of ::then(launch_policy, f). 2015-10-15 23:31:38 +02:00
Vicente J. Botet Escriba
45cc1704ef fix some missing decay. Cleanup adding init. 2015-10-15 19:19:07 +02:00
Vicente J. Botet Escriba
278a06fd47 Merge pull request #71 from jhunold/executors_fix
Fix executor forward
2015-10-12 23:49:48 +02:00
Jürgen Hunold
6ed577f4eb Fix executor forward
correct namespace and type
2015-10-12 08:01:19 +02:00
Vicente J. Botet Escriba
bf8459cf23 Merge from develop. 2015-10-11 23:34:45 +02:00
Vicente J. Botet Escriba
ad3cf1189e More fixes for some move semantic issues C++03. 2015-10-11 21:30:54 +02:00
Vicente J. Botet Escriba
b8db8fef8b Use parent executor (#11716). Add promise::set_executor and packaged_task::set_executor (#11717). Fix some move semantic issues C++03. 2015-10-11 19:56:38 +02:00
Vicente J. Botet Escriba
384c71dbe6 minor updates. 2015-10-11 18:45:58 +02:00
Vicente J. Botet Escriba
111574cf0c minor updat on configuration. 2015-10-10 15:47:28 +02:00
Vicente J. Botet Escriba
759601d08a Merge pull request #70 from mauve/fix-provides-executors-doc
doc: add PROVIDES_EXECUTORS to the config table
2015-10-10 10:26:01 +02:00
Vicente J. Botet Escriba
c60d152102 Merge pull request #69 from mauve/fix-then-docs
doc: then() on future take an executor
2015-10-10 10:24:18 +02:00
Mikael Olenfalk
6ff4fe1a89 doc: add PROVIDES_EXECUTORS to the config table 2015-10-10 09:04:38 +02:00
Mikael Olenfalk
2c0c4ead7f doc: then() on future take an executor 2015-10-10 08:54:37 +02:00
Vicente J. Botet Escriba
dacd6deb0a Add static_shared_from_this and make use of it. 2015-10-09 08:53:47 +02:00
Vicente J. Botet Escriba
c7df715709 Merge branch 'develop' 2015-10-06 23:27:17 +02:00
Vicente J. Botet Escriba
ddd26b5bb8 remove comments after \ continuator macro. 2015-10-04 18:06:59 +02:00
Vicente J. Botet Escriba
f0228ff559 fix shared_state_nullary_task_lifetime_issue_bad_use_of_direct_pointer on C++98 compilers. 2015-10-04 02:10:33 +02:00
Vicente J. Botet Escriba
4acaddd166 rollback fix shared_state_nullary_task_lifetime_issue_bad_use_of_direct_pointer on C++98 compilersas there is a compile error to fix. 2015-10-03 20:26:47 +02:00
Vicente J. Botet Escriba
3a65295d7d replace >> by > >. 2015-09-30 23:58:03 +02:00
Vicente J. Botet Escriba
773f8bfcb4 replace >> by > >. 2015-09-30 23:57:00 +02:00
Vicente J. Botet Escriba
8afcbe22af uncomment fixed test after merge from develop. 2015-09-30 00:08:16 +02:00
Vicente J. Botet Escriba
450f34daed merge from develop. 2015-09-30 00:01:33 +02:00
Vicente J. Botet Escriba
ea9eb62802 fix shared_state_nullary_task_lifetime_issue_bad_use_of_direct_pointer. 2015-09-29 21:57:52 +02:00
Vicente J. Botet Escriba
971c028c9a thread::try_join_until: Avoid busy wait if system clock changes. #11688. 2015-09-28 21:46:16 +02:00
Vicente J. Botet Escriba
3f8618b42b update release notes. 2015-09-27 16:27:06 +02:00
Vicente J. Botet Escriba
9a8759a3dd rollback physical_concurrency changes and take care of patch #10788. #11683. 2015-09-27 15:14:58 +02:00
Vicente J. Botet Escriba
9ac736a4c4 Apply patch fromPR - Do not wake up computer from sleep. #11368. 2015-09-27 14:30:16 +02:00
Vicente J. Botet Escriba
730cb550e6 Merge branch 'develop' 2015-09-27 08:24:26 +02:00
Vicente J. Botet Escriba
8f5de1d7c3 make condition_variable_any steady when BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC. 2015-09-25 07:35:25 +02:00
Vicente J. Botet Escriba
0fdd4fc620 remove comments. 2015-09-24 01:36:41 +02:00
Vicente J. Botet Escriba
a86e2ebcc4 Dont use nanosleep on sleep_for if defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC. 2015-09-24 01:25:22 +02:00
Vicente J. Botet Escriba
18cbf4b055 rollback reverse the use of dattime and chrono when chrono is acceptable. 2015-09-24 01:24:08 +02:00
Vicente J. Botet Escriba
6029447774 Merge branch 'develop' of github.com:boostorg/thread into develop 2015-09-24 00:08:22 +02:00
Vicente J. Botet Escriba
205a1d7e2b apply patch ref #7720. 2015-09-24 00:07:11 +02:00
Vicente J. Botet Escriba
2af9c7b98e Merge pull request #66 from BenWiederhake/fix-auto-ptr/develop
Avoid deprecated auto_ptr
2015-09-19 19:59:25 +02:00
Ben Wiederhake
baca517058 Avoid deprecated auto_ptr 2015-09-19 18:14:41 +02:00
Vicente J. Botet Escriba
26486b0288 Merge pull request #65 from mclow/develop
Remove use of deprecated macros in documentation
2015-09-12 08:50:27 +02:00
Marshall Clow
f8ff41e34b Remove use of deprecated macros in documentation 2015-09-11 15:30:34 -07:00
Vicente J. Botet Escriba
16ece266a4 Merge pull request #64 from MarcelRaad/patch-1
Fix for future with RTTI off
2015-09-11 18:32:59 +02:00
Marcel Raad
4224a9f4df Fix for future with RTTI off
895b4a0ac5 introduced dynamic_casts. This breaks boost::future with RTTI turned off, which worked before. static_casts should be enough here.
2015-09-11 11:06:32 +02:00
Vicente J. Botet Escriba
2e17e028b1 use serial_executor instead of serial_executor_cont. 2015-09-08 21:55:48 +02:00
Vicente J. Botet Escriba
febe4a814d comment trace to see the error. 2015-09-08 21:39:33 +02:00
Vicente J. Botet Escriba
242cf35c51 Try patch for oldticket #3926 - thread_specific_ptr + dlopen library causes a SIGSEGV 2015-09-08 19:24:15 +02:00
Vicente J. Botet Escriba
c1ee2bfbd8 fix issue with latch:wait when count is already 0. 2015-09-08 18:25:20 +02:00
Vicente J. Botet Escriba
b30cde32d4 reverse the use of dattime and chrono when chrono is acceptable. 2015-09-08 18:22:44 +02:00
Vicente J. Botet Escriba
ac3f7eb037 comment sleep_for overload on nanoseconds on windows. 2015-09-05 16:17:36 +02:00
Vicente J. Botet Escriba
9f883f6ad7 Add a possible implementation of a steady condition_variable. 2015-09-03 23:44:03 +02:00
Vicente J. Botet Escriba
b332f17825 Added failing test for #11611. 2015-09-02 22:39:26 +02:00
Vicente J. Botet Escriba
a3497e1ffc Merge branch 'develop' 2015-08-22 07:20:49 +02:00
Vicente J. Botet Escriba
89b119f65f Merge branch 'develop' of github.com:boostorg/thread into develop 2015-08-21 18:38:14 +02:00
Vicente J. Botet Escriba
1ae07f3f3a Add shared_timed_mutex typedef. 2015-08-21 18:37:42 +02:00
Vicente J. Botet Escriba
0143748de8 Add test_11499. 2015-08-21 18:37:08 +02:00
Vicente J. Botet Escriba
ac603f6bd1 fix devector allocator_traits_type specific usage. 2015-08-21 18:35:36 +02:00
Vicente J. Botet Escriba
6aeac1e33e Merge pull request #61 from jzmaddock/patch-2
Move Oracle workaround to correct location
2015-08-21 00:00:38 +02:00
jzmaddock
ff375e2780 Move Oracle workaround to correct location 2015-08-20 10:51:23 +01:00
Vicente J. Botet Escriba
5b1c755e42 Merge pull request #60 from jzmaddock/patch-1
Fix to get Thread lib building with Oracle C++
2015-08-19 06:33:59 +02:00
jzmaddock
b8dbe960b7 Fix to get Thread lib building with Oracle C++
See https://svn.boost.org/trac/boost/ticket/11550
2015-08-18 18:20:25 +01:00
Vicente J. Botet Escriba
4f9a08c418 fix for(;;){} . 2015-07-01 13:21:39 +02:00
Vicente J. Botet Escriba
44272d3b7c fix for(;;); . 2015-06-29 08:43:01 +02:00
Vicente J. Botet Escriba
ccd1cd5808 fix Link to archived copy of article. 2015-06-28 11:27:02 +02:00
Vicente J. Botet Escriba
8c974800f9 try to remove yet more warnings. 2015-06-23 19:05:32 +02:00
Vicente J. Botet Escriba
6e002ae3ec try to remove more warnings. 2015-06-21 23:09:15 +02:00
Vicente J. Botet Escriba
2a375808c4 Merge branch 'develop' of github.com:boostorg/thread into develop 2015-06-21 17:38:13 +02:00
Vicente J. Botet Escriba
55c21919fc try to remove some warnings. 2015-06-21 17:37:30 +02:00
Vicente J. Botet Escriba
91e2cded63 Merge pull request #57 from MarcelRaad/patch-1
Fix typo
2015-06-05 18:12:58 +02:00
Marcel Raad
b980b88474 Fix typo
There was a typo in the code with both BOOST_USE_WINDOWS_H and BOOST_NO_ANSI_APIS defined.
2015-06-05 17:48:53 +02:00
Vicente J. Botet Escriba
7cb5211e25 fix typo on poly lockables. 2015-05-29 20:02:08 +02:00
Vicente J. Botet Escriba
958b773d05 Merge from develop. 2015-05-18 22:35:17 +02:00
Vicente J. Botet Escriba
4d45da6c06 Apply patch #11302. 2015-05-18 21:26:46 +02:00
Vicente J. Botet Escriba
e39703ff18 Merge branch 'develop' of github.com:boostorg/thread into develop 2015-05-15 15:07:08 +02:00
Vicente J. Botet Escriba
aafd5ca726 applie patch for #11266. 2015-05-15 15:05:09 +02:00
Vicente J. Botet Escriba
9b69912801 Merge pull request #54 from tempoz/patch-5
Remove unused parameter
2015-05-14 18:18:31 +02:00
Vicente J. Botet Escriba
259c08473d Merge branch 'develop' of github.com:boostorg/thread into develop 2015-05-14 18:08:52 +02:00
Vicente J. Botet Escriba
6ca3a99cbc Merge pull request #56 from danieljames/link-fix
Link to archived copy of article.
2015-05-12 22:39:59 +02:00
Daniel James
3dcd875944 Link to archived copy of article.
The original is no longer available.

Fixes: https://svn.boost.org/trac/boost/ticket/11185
2015-05-12 18:52:23 +01:00
Vicente J. Botet Escriba
58e8addad6 Try to get rid of bad link issue while defining global new. 2015-05-06 13:51:21 +02:00
Vicente J. Botet Escriba
87615d54dd cleanup unused function set_exceptional_if_invalid. 2015-05-06 09:48:54 +02:00
Vicente J. Botet Escriba
d322aba077 Merge pull request #55 from jessicah/tests-fix-error-message
Tests: correct #error message in recursive_mutex/native_handle_pass
2015-05-05 20:50:32 +02:00
Jessica Hamilton
c0afe2d873 Tests: correct #error message in recursive_mutex/native_handle_pass 2015-05-06 02:14:13 +12:00
Vicente J. Botet Escriba
5488482a44 simplify launch_continuation interface. 2015-05-04 23:06:39 +02:00
Vicente J. Botet Escriba
1480d6fc99 simplify launch_continuation interface. 2015-05-04 18:24:09 +02:00
Vicente J. Botet Escriba
131c92a7d8 propagate unwrap fixes. 2015-05-04 00:19:12 +02:00
Vicente J. Botet Escriba
71d9a0a120 fix issue with unwrap shared state. Take care of exceptions on the unwrapped future. 2015-05-03 22:52:52 +02:00
Vicente J. Botet Escriba
b7b2a463cf fix issue with unwrap shared state. 2015-05-03 22:32:17 +02:00
Vicente J. Botet Escriba
c50d0ac4ba try to fix issue with continuation on unwrap shared state. 2015-05-03 16:51:41 +02:00
Vicente J. Botet Escriba
1b2736012c Merge branch 'fix/basic_thread_pool_bad_use_of_scoped_thread' into develop 2015-05-03 14:36:57 +02:00
Vicente J. Botet Escriba
5205fa71bf Fixed some missing lock.unlock(). 2015-05-03 14:30:52 +02:00
Vicente J. Botet Escriba
ba2988a8f7 Fixed issue with basic_thread_pool scoped threads. 2015-05-03 10:42:42 +02:00
Vicente J. Botet Escriba
650956bd3b First draft of non-blocking. Fixed issue with basic_thread_pool scoped threads. Now when the result of async(ex,f) is not stored, there is a lifetime issue with shared_state_nullary_task use of direct pointer to the shared state, however there is some weak_ptr issues :(. 2015-05-03 10:13:08 +02:00
Vicente J. Botet Escriba
e598796eaf Add assertion on future continuation parameter is ready. As noted in #11256, there some serious issues with the parameter passed and with lock on locked mutextes :(. 2015-05-02 16:29:06 +02:00
Vicente J. Botet Escriba
bce7eabba2 fix make_exceptional issue. 2015-04-30 01:11:39 +02:00
Vicente J. Botet Escriba
0218136ed7 Try to see if share_from_this helps on the thread sanitize data race. 2015-04-25 15:41:49 +02:00
Vicente J. Botet Escriba
461bf803fc Avoid data race in std::cout. 2015-04-25 11:17:20 +02:00
Vicente J. Botet Escriba
1bd78bbeea cleanup commented code. 2015-04-25 11:16:03 +02:00
Vicente J. Botet Escriba
348da6b7e4 fix memory leack in test. 2015-04-25 10:11:01 +02:00
Vicente J. Botet Escriba
e850218c49 ref #11174 - boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite. 2015-04-25 00:20:53 +02:00
Vicente J. Botet Escriba
385eefd3b3 ref #11174 - boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite. 2015-04-25 00:20:05 +02:00
Zoey Greer
2ddf7aad0b Remove unused parameter
lk is unused in get_state, naming it causes build warnings
2015-04-22 19:37:36 -04:00
Vicente J. Botet Escriba
c9433c2a5b rollback ref #11174 - boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite. 2015-04-22 22:49:26 +02:00
Vicente J. Botet Escriba
8853a4cbdf ref #11174 - boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite. 2015-04-22 07:23:38 +02:00
Vicente J. Botet Escriba
6f53279b50 ref #11174 - boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite. 2015-04-18 19:26:07 +02:00
Vicente J. Botet Escriba
f25bc8bbab Merge branch 'develop' 2015-04-18 11:56:34 +02:00
Vicente J. Botet Escriba
5c442e068c update compliance. 2015-04-18 07:10:43 +02:00
Vicente J. Botet Escriba
0bed674233 ref #11192- boost::future<>::then() with an executor doesn't compile when the callback returns a future 2015-04-18 07:04:50 +02:00
Vicente J. Botet Escriba
66193b0d38 Test with generic lambdas. 2015-04-17 18:31:34 +02:00
Vicente J. Botet Escriba
45c9a1d7fd ref #11192- boost::future<>::then() with an executor doesn't compile when the callback returns a future 2015-04-17 18:30:49 +02:00
Niall Douglas
0d8ddfe378 Merge pull request #51 from MarcelRaad/patch-1
Respect BOOST_USE_WINDOWS_H again
2015-04-03 17:11:17 +01:00
Vicente J. Botet Escriba
74f479d5c9 Fix non_copyable class in queue/dequeue view tests. 2015-03-29 19:34:28 +02:00
Vicente J. Botet Escriba
dbf793e7eb Don't execute test for launch::deferred if BOOST_THREAD_PROVIDES_VARIADIC_THREAD is not defined. 2015-03-29 19:28:05 +02:00
Marcel Raad
b5c6f760c5 Respect BOOST_USE_WINDOWS_H again
With the GetTickCount64 and WinRT fixes, the Windows API functions were always re-declared regardless of BOOST_USE_WINDOWS_H. This breaks clang-cl, which complains about conflicting definitions.
2015-03-26 13:43:44 +01:00
Vicente J. Botet Escriba
0f6a3ebbe5 Merge branch 'develop' 2015-03-21 15:44:02 +01:00
Vicente J. Botet Escriba
a5c34e7be2 update version and copyright. 2015-03-21 15:43:04 +01:00
Vicente J. Botet Escriba
287100119a Merge branch 'develop' 2015-03-17 03:16:35 +01:00
Vicente J. Botet Escriba
ba2f814342 Don't lock while storing the exception_ptr list as only the task_region thread can do it. 2015-03-16 08:41:04 +01:00
Vicente J. Botet Escriba
5169a5414b mutex::unlock must not throw. 2015-03-14 16:26:35 +01:00
Vicente J. Botet Escriba
82b9a4e28c Use coherently size_type. 2015-03-12 04:09:34 +01:00
Vicente J. Botet Escriba
e989d2f626 Add comments. 2015-03-12 04:08:42 +01:00
Vicente J. Botet Escriba
331f0b9325 Added test for future<T&>::get_or. 2015-03-10 07:54:09 +01:00
Vicente J. Botet Escriba
ec6a1fcf80 try to get rid of data race. 2015-03-10 00:48:12 +01:00
Vicente J. Botet Escriba
dcebe26a11 try to get rid of possible deadlock. 2015-03-10 00:47:38 +01:00
Vicente J. Botet Escriba
d7721940f3 update history. 2015-03-09 23:17:35 +01:00
Vicente J. Botet Escriba
b678edb0d8 update history. 2015-03-08 23:31:37 +01:00
Vicente J. Botet Escriba
1371728e02 Merge pull request #50 from wmamrak/develop
Fixed some documentation bugs.
2015-03-06 00:11:52 +01:00
Wojciech Mamrak
17d802db81 Fixed documentation bugs. 2015-03-05 13:22:04 +01:00
Wojciech Mamrak
9fc06a8741 Fixed documentation bugs. 2015-03-05 12:37:10 +01:00
Wojciech Mamrak
946fac633e Fixed documentation bugs. 2015-03-04 12:22:33 +01:00
Wojciech Mamrak
af1c7d0c26 Fixed documentation bugs. 2015-03-03 19:03:18 +01:00
Vicente J. Botet Escriba
d9594e7fc8 Merge branch 'develop' 2015-03-01 18:54:42 +01:00
Vicente J. Botet Escriba
0653efff3d Added this_executor and default_executor examples. 2015-03-01 18:53:11 +01:00
Vicente J. Botet Escriba
566199e49b Added this_executor and default_executor examples. 2015-03-01 18:37:16 +01:00
Vicente J. Botet Escriba
c7bb6fa318 Allow timed and recursive mutex on ANDROID. Related to #11035. 2015-03-01 01:37:45 +01:00
Vicente J. Botet Escriba
c678b3794b Crash issue while calling run_thread_exit_callbacks. Related to #11053. 2015-03-01 01:37:35 +01:00
Vicente J. Botet Escriba
e0ce8af1d9 cleanup work.hpp 2015-02-28 12:39:03 +01:00
Vicente J. Botet Escriba
c54dbe30a2 move the work parameter. 2015-02-28 12:37:27 +01:00
Vicente J. Botet Escriba
b8763b05ad Add missing push(movable&&) and Run some failing tests that work when BOOST_NO_CXX11_RVALUE_REFERENCES is not defined. 2015-02-28 12:35:42 +01:00
Vicente J. Botet Escriba
3755af2063 Run some failing tests that work when BOOST_NO_CXX11_RVALUE_REFERENCES is not defined. 2015-02-28 12:35:23 +01:00
Vicente J. Botet Escriba
41172e4814 fix missing include in caller_context.hpp and let the possibility to dump function at compile time. 2015-02-28 12:33:46 +01:00
Vicente J. Botet Escriba
25310eaf7c make use of nullary_function<void()> as work for timed schedulers (priority_queue) on C++11. 2015-02-22 23:44:34 +01:00
Vicente J. Botet Escriba
55f9563f60 Merge branch 'fix/blocking_future' into develop 2015-02-20 16:36:18 +01:00
Vicente J. Botet Escriba
ec770eeb6a fix forwarding reference_wrapper in make_ready_future. 2015-02-20 16:34:56 +01:00
Vicente J. Botet Escriba
b9ab307912 rollback nullary_function<void()const> specialization. 2015-02-20 16:33:53 +01:00
Vicente J. Botet Escriba
83ced837fa rollback nullary_function specialization as is the cause of compile failures. 2015-02-20 15:33:26 +01:00
Vicente J. Botet Escriba
ce2b2801d6 Merge branch 'fix/blocking_future' into develop 2015-02-20 14:37:10 +01:00
Vicente J. Botet Escriba
1ae96b3820 Merge branch 'develop' into fix/blocking_future 2015-02-20 14:34:55 +01:00
Vicente J. Botet Escriba
889c178173 fix issues with fallback_to. The route cause was that the original future was locked after destruction. This was more evident when the future was already ready when future::then was called. 2015-02-20 14:34:33 +01:00
Vicente J. Botet Escriba
7ba9591015 first trial towards a work=nullary_function<void() const>. 2015-02-20 10:20:38 +01:00
Vicente J. Botet Escriba
b07f18facf remove include/boost/thread/detail/work.hpp. 2015-02-20 10:18:35 +01:00
Vicente J. Botet Escriba
7b1b1b5daa fix include guard on serial_executor_cont.hpp. 2015-02-19 18:00:29 +01:00
Vicente J. Botet Escriba
63fb28c7d4 Merge branch 'develop' into fix/blocking_future 2015-02-19 10:36:20 +01:00
Vicente J. Botet Escriba
67e18ff039 Merge branch 'feature/serial_executor_continuation' into develop 2015-02-19 10:31:39 +01:00
Vicente J. Botet Escriba
e715d74a95 use a different name for serial_executor continuation as it add more constraints. 2015-02-19 10:30:25 +01:00
Vicente J. Botet Escriba
393d214ac9 Merge branch 'develop' into feature/serial_executor_continuation 2015-02-19 10:16:27 +01:00
Vicente J. Botet Escriba
855e56076b Merge branch 'develop' 2015-02-19 08:59:18 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
0fa6038f6a Revert "Make mandatory that the Win32 API version configured is at least Windows XP or higher."
This reverts commit e0217424f3.
2015-02-18 23:40:46 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
cf1182ee99 Disable physical_concurrency() on Mingw32 alone. 2015-02-18 15:19:48 +00:00
Vicente J. Botet Escriba
a04497af24 make thread-safe serial_executor. There are yet somme synchronization limitations. 2015-02-18 10:45:10 +01:00
Vicente J. Botet Escriba
821a93ca1a first draft for serial_executor based on continuations. 2015-02-17 19:09:56 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
e0217424f3 Make mandatory that the Win32 API version configured is at least Windows XP or higher. 2015-02-17 14:42:39 +00:00
Vicente J. Botet Escriba
cf76bc666c Merge branch 'develop' into fix/blocking_future 2015-02-17 11:44:04 +01:00
Vicente J. Botet Escriba
d00e39acc7 Add traces to sporious fali on fallback_to. 2015-02-17 11:41:21 +01:00
Vicente J. Botet Escriba
90ba3ae7c6 Merge pull request #48 from wmamrak/develop
Fixed documentation bugs.
2015-02-17 11:25:58 +01:00
Vicente J. Botet Escriba
b68702b56d Merge branch 'develop' into fix/blocking_future 2015-02-17 01:50:11 +01:00
Wojciech Mamrak
3b2322db96 Fixed documentation bugs. 2015-02-17 00:52:39 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
6a427ac4b6 Fix physical_concurrency() on win32. 2015-02-16 18:03:46 +00:00
Vicente J. Botet Escriba
ffd856073f Merge branch 'develop' of github.com:boostorg/thread into develop 2015-02-16 14:28:00 +01:00
Vicente J. Botet Escriba
f1fafb117a fix typo. 2015-02-16 14:27:37 +01:00
Vicente J. Botet Escriba
e2cda49b0b cleanup. unlock before submiting to an executor as it can directly call the continuation. 2015-02-16 14:17:57 +01:00
Vicente J. Botet Escriba
d1aa2eec56 Merge pull request #47 from wmamrak/develop
Removed redundant move ctor and ass. operator of Thread class synopsis.
2015-02-15 23:56:24 +01:00
Wojciech Mamrak
1db0ba4639 Removed redundant move ctor and ass. operator of Thread class synopsis. 2015-02-15 20:49:07 +01:00
Vicente J. Botet Escriba
a4e7eba1d4 cleanup. 2015-02-11 07:05:10 +01:00
Vicente J. Botet Escriba
67778b3278 fix shared_future::then, get and get_or. 2015-02-10 00:01:28 +01:00
Vicente J. Botet Escriba
a5e6952a95 merge from develop - coamesced timers. 2015-02-09 13:08:55 +01:00
Vicente J. Botet Escriba
3c6a183aa3 Merge branch 'develop' 2015-02-08 18:19:07 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
9cc1357c95 Revert "Try to include some STL headers which Android libc++ claims have not been included."
This reverts commit b571686e5d.
2015-02-06 12:21:55 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
b571686e5d Try to include some STL headers which Android libc++ claims have not been included. 2015-02-06 12:09:52 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
9c67be287e Fix warning on mingw about casting a function pointer through a void *.
Fix warning on MSVC about GetModuleHandle potentially failing.
2015-02-06 12:04:22 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
f599783444 Fixed the MSVC10 breakage caused by coalesced timers support. 2015-02-06 11:51:37 +00:00
Vicente J. Botet Escriba
d628b8d36c Merge branch 'develop' of github.com:boostorg/thread into develop 2015-02-05 08:30:39 +01:00
Vicente J. Botet Escriba
65c519c22c Merge branch 'master' into develop 2015-02-04 22:35:29 +01:00
Vicente J. Botet Escriba
05e492c56c Merge branch 'master' of github.com:boostorg/thread 2015-02-04 22:33:22 +01:00
Vicente J. Botet Escriba
3c2321c37a Merge pull request #45 from Matulis/master
Updated namespace to call no_interruption_point sleep_for
2015-02-04 22:31:11 +01:00
Martin Matulyauskas
6c72a2527f Updated namespace to call no_interruption_point sleep_for 2015-02-04 15:00:51 -06:00
Niall Douglas
1bd09085db Merge pull request #44 from boostorg/win32_coalesced_timers_support
Win32 coalesced timers support
2015-02-04 18:14:40 +00:00
Vicente J. Botet Escriba
d6c3f15947 Merge branch 'develop' 2015-02-04 18:47:40 +01:00
Vicente J. Botet Escriba
5960985355 merge from develop: Reverted parts of c16ec42 because 45510fa was a better fix.: 2015-02-04 18:46:29 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
84e2b7869d Merge branch 'develop' of github.com:boostorg/thread into develop 2015-02-04 13:58:30 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
401f69f108 Added coalesced timer support to Windows where that API is available. Tolerable delay is set to the maximum of 5% of interval or 32 ms. 2015-02-04 13:58:11 +00:00
Vicente J. Botet Escriba
4f57e3fb61 Merge pull request #43 from vtnerd/RevertMakeReady
Reverted parts of c16ec42 because 45510fa was a better fix.
2015-02-03 08:34:53 +01:00
Vicente J. Botet Escriba
fdf20f1adc merge Allow to call shared_future::then multiple times. Related to #10972. 2015-02-02 19:40:04 +01:00
Lee Clagett
990474ff47 Reverted parts of c16ec42 because 45510fa was a better fix. 2015-02-02 12:08:38 -05:00
Vicente J. Botet Escriba
786d842ad1 update history. 2015-02-02 17:45:57 +01:00
Vicente J. Botet Escriba
441c89d304 Allow to call shared_future::then multiple times. Related to #10972. 2015-02-02 17:41:57 +01:00
Vicente J. Botet Escriba
63098e84a2 Merge branch 'develop' into fix/blocking_future 2015-02-01 19:39:43 +01:00
Vicente J. Botet Escriba
71997bd9aa Merge branch 'develop' 2015-02-01 19:38:50 +01:00
Vicente J. Botet Escriba
45510facc7 unwrapped future must forward the continuation to the wrapped future. Related to #10964. 2015-02-01 14:56:52 +01:00
Vicente J. Botet Escriba
cf539064d6 Deduce T& when the make_ready_future parameter is reference_wrapper<T>. Relates to #10979. 2015-02-01 13:44:41 +01:00
Vicente J. Botet Escriba
3431736c88 Merge branch 'develop' into fix/blocking_future 2015-01-27 22:22:37 +01:00
Vicente J. Botet Escriba
095b53b2a2 Update changes. 2015-01-27 07:14:17 +01:00
Vicente J. Botet Escriba
7a63c40a01 Merge pull request #39 from jhunold/shadow
Fix gcc/clang shadow warnings.
2015-01-26 19:48:53 +01:00
Jürgen Hunold
c1148a66cc Fix gcc/clang shadow warnings.
The variable names are re-used in the all_futures_lock() functions.
2015-01-26 12:39:27 +01:00
Vicente J. Botet Escriba
5fa0a5d4c5 make shared_future::get() const. Related to #10971. 2015-01-26 08:39:30 +01:00
Vicente J. Botet Escriba
75a8280701 Merge branch 'develop' 2015-01-25 16:00:08 +01:00
Vicente J. Botet Escriba
2891aff469 Add missing file . 2015-01-24 18:43:56 +01:00
Vicente J. Botet Escriba
e74fd82060 Merge from develop. 2015-01-24 18:02:31 +01:00
Vicente J. Botet Escriba
c16ec42941 Take care of #10964. 2015-01-24 16:48:44 +01:00
Vicente J. Botet Escriba
b77eac3e37 Take care of #10963. 2015-01-24 11:57:54 +01:00
Vicente J. Botet Escriba
5a141ccf99 Merge branch 'develop' 2015-01-24 09:07:25 +01:00
Vicente J. Botet Escriba
35d7ae0d2e add forgotten wait when shared_future::then deferred. 2015-01-23 08:36:46 +01:00
Vicente J. Botet Escriba
d9c7f95617 fix future async deferred. 2015-01-23 07:10:22 +01:00
Vicente J. Botet Escriba
06b3f6a9d7 disable async deferred on C++98 as not implemented. 2015-01-23 06:02:11 +01:00
Vicente J. Botet Escriba
895b4a0ac5 Try to fix a lot of issues, even if alldoesn't works yet. 2015-01-22 23:10:40 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
eb14d3d958 Added a test for defect #9856 where wait_for() is not always returning timedout on Windows. 2015-01-22 17:20:46 +00:00
Vicente J. Botet Escriba
9cb72849ee Go towards blocking on the last future associated to an async shared state. shared_future don't work yet. 2015-01-18 12:19:17 +01:00
Vicente J. Botet Escriba
2c028aa014 fix more erros after Boost.Test commit. 2015-01-12 00:36:55 +01:00
Vicente J. Botet Escriba
ab026e239c Fix erros after Boost.Test adding dependency to Boost.Timer. 2015-01-11 18:21:22 +01:00
Vicente J. Botet Escriba
3a48148462 Fix Boost.Test issues after meger :(. 2015-01-11 17:30:54 +01:00
Vicente J. Botet Escriba
9b9590730f Merge branch 'master' of github.com:boostorg/thread 2015-01-11 17:00:10 +01:00
Vicente J. Botet Escriba
8edc37930b Merge pull request #38 from raffienficiaud/master
Some fixes of boost.test init and link fix
2015-01-11 16:58:14 +01:00
Raffi Enficiaud
ef48908f35 Merge branch 'master' of https://github.com/boostorg/thread
# By Vicente J. Botet Escriba (274) and others
# Via Vicente J. Botet Escriba (42) and others
* 'master' of https://github.com/boostorg/thread: (318 commits)
  Added missing include.
  cleanup future.hpp.
  Updated CI dashboard with latest tests.
  Looks like timeconv.inl may be completely unnecessary, so remove.
  Could find no code anywhere in Boost which uses to_time(), to_timespec_duration(), to_duration() nor to_microduration(), so removed the code.
  Fixed MSVC static analyser warning about writing off the end of an array.
  Stop LNK4221 link warning with link=static.
  Suppressed some unimportant warnings so the CI doesn't flag them.
  Added static analysers to CI dashboard.
  Added winphone8 build test.
  Fix failure to build on Android.
  redo
  Added overall build and test status
  Added test matrix to Readme.md so a summary appears on github
  fix some typos.
  ensure that the exceptions throw by a task submitted by a serial executor are transfered to it, and so the serial_executor doesn't block forever.
  No comment after preprocessor continuation for msvc-12.0
  Added  ! defined __clang__ when tested defined __GNUC__.
  Added BOOST_THREAD_PROVIDES_INVOKE constraing for invoker.
  thread: physical_concurrency - return 0 instead of hardware_concurrency on failure
  ...

Conflicts:
	test/test_2741.cpp
2015-01-11 16:22:32 +01:00
Raffi Enficiaud
28ead512c1 some reworked test init + boost.test link fix 2015-01-11 16:21:32 +01:00
Vicente J. Botet Escriba
6b60943f3e Added csbl/queue.hpp and concurrent_queues/detail/sync_deque_base.hpp dradt. 2015-01-10 16:09:15 +01:00
Vicente J. Botet Escriba
1fcaa47efa extract future_error,future_status and launch. 2015-01-10 09:02:37 +01:00
Vicente J. Botet Escriba
aac441392a extract wait_for_any for sequences. 2015-01-09 08:09:34 +01:00
Vicente J. Botet Escriba
6a34fc9c33 moved future_error_code.hpp file. 2015-01-09 08:08:03 +01:00
Vicente J. Botet Escriba
69d01b9bfd extract wait_for_all into futures/wait_for_all.hpp. 2015-01-07 07:13:48 +01:00
Vicente J. Botet Escriba
7b91ce7b64 move future_error_code.hpp to futures. 2015-01-07 06:42:27 +01:00
Vicente J. Botet Escriba
978884ff0d extracted futures/is_future_type.hpp. 2015-01-07 06:22:20 +01:00
Vicente J. Botet Escriba
ac8ca6eb04 Added notify_when_ready/unnotify_when_ready. 2015-01-07 04:53:50 +01:00
Vicente J. Botet Escriba
1c16c52fe6 Added missing include. 2015-01-04 17:41:52 +01:00
Vicente J. Botet Escriba
9299d26acf cleanup future.hpp. 2014-12-30 11:47:15 +01:00
Niall Douglas
5577128bd8 Merge pull request #37 from ned14/develop
Remove timeconv.inl files as apparently no longer used.
2014-12-14 20:31:21 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
e62c576944 Updated CI dashboard with latest tests. 2014-12-14 19:20:11 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
ce8049f83f Looks like timeconv.inl may be completely unnecessary, so remove. 2014-12-14 02:01:13 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
035217985c Could find no code anywhere in Boost which uses to_time(), to_timespec_duration(), to_duration() nor to_microduration(), so removed the code. 2014-12-14 01:38:50 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
dfe95b3f2c Fixed MSVC static analyser warning about writing off the end of an array. 2014-12-14 01:15:49 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
e98447f974 Stop LNK4221 link warning with link=static. 2014-12-14 00:52:17 +00:00
Vicente J. Botet Escriba
deffa9aaf7 Merge pull request #36 from ned14/develop
Add static analysers to CI dashboard, and suppress unimportant warnings
2014-12-11 23:10:51 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
b87d26a900 Suppressed some unimportant warnings so the CI doesn't flag them. 2014-12-11 19:15:38 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
6c9115fe39 Added static analysers to CI dashboard. 2014-12-11 15:48:37 +00:00
Vicente J. Botet Escriba
b5b25eab1c Merge pull request #35 from ned14/develop
Added test matrix to Readme.md so a summary appears on github
2014-12-10 19:38:01 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
803ba458ce Added winphone8 build test. 2014-12-10 17:26:50 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
c0470893d4 Fix failure to build on Android. 2014-12-10 14:36:29 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
b2c445a030 redo 2014-12-10 14:32:46 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
6e37c55221 Added overall build and test status 2014-12-10 14:31:10 +00:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
e1039e61f3 Added test matrix to Readme.md so a summary appears on github 2014-12-10 14:20:55 +00:00
Vicente J. Botet Escriba
063b59e511 fix some typos. 2014-12-07 19:03:59 +01:00
Vicente J. Botet Escriba
a342d1ccee Merge pull request #33 from jhunold/fix_comment
No comment after preprocessor continuation for msvc-12.0
2014-12-06 10:50:55 +01:00
Vicente J. Botet Escriba
811f3df98d ensure that the exceptions throw by a task submitted by a serial executor are transfered to it, and so the serial_executor doesn't block forever. 2014-12-06 10:47:43 +01:00
Jürgen Hunold
8e1be55c6d No comment after preprocessor continuation for msvc-12.0 2014-12-05 22:11:35 +01:00
Vicente J. Botet Escriba
421469686d Added ! defined __clang__ when tested defined __GNUC__. 2014-12-03 22:40:34 +01:00
Vicente J. Botet Escriba
72dfa02269 Added BOOST_THREAD_PROVIDES_INVOKE constraing for invoker. 2014-12-03 22:37:42 +01:00
Vicente J. Botet Escriba
4c48b2276c Merge pull request #32 from timblechmann/topic/physical_concurrency_fix
Topic/physical concurrency fix
2014-11-29 14:25:48 +01:00
Tim Blechmann
8c7275cb9e thread: physical_concurrency - return 0 instead of hardware_concurrency on failure 2014-11-29 11:44:04 +01:00
Tim Blechmann
14c5cff2ee thread: physical_concurrency - windows xp does not provide GetLogicalProcessorInformation 2014-11-29 11:43:36 +01:00
Vicente J. Botet Escriba
83f38ea52c fix detail::priority_queue_top. 2014-11-23 16:47:33 +01:00
Vicente J. Botet Escriba
06a9f9ab6d Added Clock parameter to scheduler and priority_timed_queue. Fix warnings in tests. 2014-11-17 07:34:43 +01:00
Vicente J. Botet Escriba
e7f140cab6 replace >> by > >. 2014-11-14 20:14:03 +01:00
Vicente J. Botet Escriba
1b99fe5587 Replace range-based for loops to make the code more portable. 2014-11-14 08:45:16 +01:00
Vicente J. Botet Escriba
b9a70f7aca don't use std::vector with msvc.a 2014-11-14 00:25:51 +01:00
Vicente J. Botet Escriba
ca87cbf57b workaround bug on Boost.Config that left the section private after using the macro BOOST_DELETED_FUNCTION. 2014-11-11 22:32:25 +01:00
Vicente J. Botet Escriba
929dc55a5a Add default Container parameter to sync_queue/sync_deque as csbl::devector. 2014-11-10 00:40:02 +01:00
Vicente J. Botet Escriba
b29d9f850c Added devector, a minimal vector providing pop_front that can be used as Container of the sync queues. 2014-11-09 20:32:58 +01:00
Vicente J. Botet Escriba
1c81d8a4b1 remove BOOST_NO_CXX11_HDR_DEQUE as it doesn't exists art all :(. 2014-11-09 17:12:54 +01:00
Vicente J. Botet Escriba
7de29f4d45 fix typo in sync_priority_queue.hpp. 2014-11-09 17:12:03 +01:00
Vicente J. Botet Escriba
9b0705cb6f Added deque_views. Make use of sync_queue and refactor to use sync_queue removing _front and _back. 2014-11-09 15:39:10 +01:00
Vicente J. Botet Escriba
3abdb869df Reduce the interface of sync_quue to the queue operations, removing the deprecated ones and removing _front and _back. 2014-11-09 14:12:28 +01:00
Vicente J. Botet Escriba
f90e76a59c Added sync_deque. 2014-11-09 13:45:05 +01:00
Vicente J. Botet Escriba
d4c8185cc9 Added priority_executor_base and refactor scheduled_executor_base. 2014-11-09 12:20:15 +01:00
Vicente J. Botet Escriba
e6501b5485 cleanup scheduled executors. 2014-11-09 11:37:18 +01:00
Vicente J. Botet Escriba
1ae3cb65f7 Make task_region more portable using Boost.Config helper macros. 2014-11-08 23:22:37 +01:00
Vicente J. Botet Escriba
a8ad389bdd Merge branch 'develop' into feature/task_region 2014-11-06 07:42:36 +01:00
Vicente J. Botet Escriba
69c1d40750 Merge branch 'develop' into feature/promise_set_value_emplace 2014-11-05 23:43:02 +01:00
Vicente J. Botet Escriba
58698f44f1 More renamming and added some comments on scheduler.hpp. 2014-11-05 19:41:56 +01:00
Vicente J. Botet Escriba
37afdd2e9a Moved test_scheduler_p to a explicit test_suite. 2014-11-05 01:03:44 +01:00
Vicente J. Botet Escriba
c87b24923a Added scheduler at/after/on executor factory helper functions. 2014-11-05 00:41:29 +01:00
Vicente J. Botet Escriba
1210fc4859 Add missing include file. 2014-11-05 00:38:21 +01:00
Vicente J. Botet Escriba
d8b6ae6266 Ensure that the numbers of pools is at least 1. 2014-11-05 00:37:52 +01:00
Vicente J. Botet Escriba
04e2223d5e Minor renamming. 2014-11-04 22:51:25 +01:00
Vicente J. Botet Escriba
579748e7a0 Avoid locking while doing callback. 2014-11-04 22:48:57 +01:00
Vicente J. Botet Escriba
41c3914aaf Don't try-catch on try_executing_one_task. 2014-11-02 19:42:18 +01:00
Vicente J. Botet Escriba
8693eec4a4 Make submit strong-thread safe. 2014-11-02 19:41:57 +01:00
Vicente J. Botet Escriba
3f699750a8 Avoid locking while doing callback. 2014-11-02 19:41:42 +01:00
Vicente J. Botet Escriba
4f8243cf59 Remove waiting_empty_. 2014-11-02 19:41:25 +01:00
Vicente J. Botet Escriba
4f01891da7 Added not_ready and timeout queue_op_status. Make sync_timed_queue and sync_priority_queue conform to the sync_queue interface. Aapt the test to the new interface. 2014-11-02 15:13:37 +01:00
Vicente J. Botet Escriba
efab5af918 Fix inspection issue. 2014-11-02 15:11:28 +01:00
Vicente J. Botet Escriba
4d03b410a8 Update executors doc adding thread executor. 2014-11-02 15:10:15 +01:00
Vicente J. Botet Escriba
c1925df81c Fix task exception silently ignored. Make submit throw if closed. join the threads created by the thread_executor 2014-11-02 15:09:11 +01:00
Vicente J. Botet Escriba
cbf9fe8a5c Fix inspection issues. 2014-11-02 15:08:44 +01:00
Vicente J. Botet Escriba
6fd7dc0d94 Added move semantics for C++11 compilers. Need of a detail::priority_queue. Tried to do it for C++98, but heap_push/heap_pop algorithms are not move aware:(. 2014-11-01 22:18:32 +01:00
Vicente J. Botet Escriba
a2f2924298 Added missing file sync_queue_base and refactor the concurrent queues to make use of this class. 2014-11-01 22:18:09 +01:00
Vicente J. Botet Escriba
49d485f1aa Removed BOOST_THREAD_QUEUE_DEPRECATE_OLD for priority and timed queues. 2014-11-01 11:21:09 +01:00
Vicente J. Botet Escriba
d7251f223e Added sync_queue_base and refactor the concurrent queues to make use of this class. Make other refactor on priority and timed queues. 2014-11-01 11:02:18 +01:00
Vicente J. Botet Escriba
20a6ef7de8 Added wait_until_not_empty, wait_until_not_empty_or_closed. Rename _q_qempty to _not_empty. 2014-11-01 01:14:41 +01:00
Vicente J. Botet Escriba
d5c41e4c4a Added tyy_pus returning queue_op_status. Rename is_closed to closed. 2014-10-31 23:49:34 +01:00
Vicente J. Botet Escriba
b96b9904b7 move scheduled_executor_base.hpp and declare scheduled_thread_pool::worker_loop inline. 2014-10-31 08:21:27 +01:00
Vicente J. Botet Escriba
304240b206 Move priority/timed queues to concurrent name space and scheduled executors to executors name spapce. 2014-10-31 08:03:15 +01:00
Vicente J. Botet Escriba
c61c139933 merged scheduled executors GSOC project from Ian Forbed. 2014-10-31 00:19:10 +01:00
Vicente J. Botet Escriba
c3b98129e4 Added task_region documentation. 2014-10-26 19:44:32 +01:00
Vicente J. Botet Escriba
3891eeef52 fix issue with C++98 exception library. 2014-10-26 19:43:47 +01:00
Vicente J. Botet Escriba
f1370b1255 Added a task_region_handle_gen that referes to an existing executor, so that we don't create one each time. 2014-10-26 15:17:25 +01:00
Vicente J. Botet Escriba
69f2a1df72 Added fib_task_region example and allows to work without executors. 2014-10-26 13:21:25 +01:00
Vicente J. Botet Escriba
700301e382 Added exception_list and task_region. 2014-10-26 11:27:18 +01:00
Vicente J. Botet Escriba
952aa44a98 Added promise::emplace and variadic make_ready_future. 2014-10-25 23:31:09 +02:00
Vicente J. Botet Escriba
5fb51a74fe remove thread_was_interrupted and fix wait_internal pending issue. 2014-10-24 18:43:26 +02:00
Vicente J. Botet Escriba
02bb6abef4 Merge pull request #29 from awulkiew/patch-1
Change members order in win32 thread_data_base to match ctor initializer...
2014-10-23 00:39:04 +02:00
Adam Wulkiewicz
1a4bd71616 Change members order in win32 thread_data_base to match ctor initializer list. 2014-10-23 00:01:37 +02:00
Vicente J. Botet Escriba
63dd439992 update history. 2014-10-12 16:28:29 +02:00
Vicente J. Botet Escriba
1029fa9c59 take in account deferred/ready futures on variadic when_all/when_any. 2014-10-12 15:47:16 +02:00
Vicente J. Botet Escriba
3e28ea806c Added deferred then tests. 2014-10-11 07:33:57 +02:00
Vicente J. Botet Escriba
07dc40a9ff Added missing boost/config.hpp file when checking for BOOST_NO_CXX11_DECLTYPE. 2014-10-09 06:51:02 +02:00
Vicente J. Botet Escriba
6f91af2154 Try to address #9569. 2014-10-05 09:11:58 +02:00
Vicente J. Botet Escriba
c3cff80557 Merge branch 'develop' of github.com:boostorg/thread into develop 2014-10-05 09:07:18 +02:00
Vicente J. Botet Escriba
729c8b63bb added missing file. 2014-10-05 09:06:52 +02:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
6fe7f44ea0 Clarified issue #6782 which can now be closed. 2014-10-04 19:47:48 +01:00
Vicente J. Botet Escriba
8fd4755e79 Added shared_future::then executor. 2014-10-04 10:36:57 +02:00
Vicente J. Botet Escriba
02b007a20e Make nullary_function copyable and movable following Boost.Move. Make use of std::shared_ptr when available. 2014-10-04 10:36:44 +02:00
Vicente J. Botet Escriba
c0c78e87fc Make invoker copyable and movable following Boost.Move. 2014-10-04 10:36:31 +02:00
Vicente J. Botet Escriba
58cde5af05 Trying to use std::function for executors::work. This doesn't works yet. 2014-10-03 21:46:57 +02:00
Vicente J. Botet Escriba
c1f2c8a1f1 Added shared_ptr.hpp. 2014-10-03 21:43:50 +02:00
Vicente J. Botet Escriba
bacf5b52ec The added commented lines should work, but don't. 2014-10-03 21:42:42 +02:00
Vicente J. Botet Escriba
3babf7966e update doc for future/shared_future::then(Executor, Fct). 2014-10-02 22:34:47 +02:00
Vicente J. Botet Escriba
f3de7bf10f Add fuutre::then(ex, fct). 2014-10-02 07:36:52 +02:00
Vicente J. Botet Escriba
90154217cf Added const to shred_future::then(). 2014-10-01 08:34:34 +02:00
Vicente J. Botet Escriba
ac0b2f9ba7 minor changes to unwrap. 2014-10-01 07:55:36 +02:00
Vicente J. Botet Escriba
da739e680a Merge pull request #27 from Lastique/patch-4
Fix GCC warnings about initialization order
2014-09-30 23:54:06 +02:00
Andrey Semashev
b240b097c7 Fix GCC warnings about initialization order 2014-09-30 22:42:13 +04:00
Vicente J. Botet Escriba
debe2fb0d1 Merge pull request #26 from Lastique/patch-3
Fix compilation with BOOST_USE_WINDOWS_H defined
2014-09-30 20:38:35 +02:00
Andrey Semashev
b264ec8fc0 Fix compilation with BOOST_USE_WINDOWS_H defined
Don't use macros defined only in Windows SDK 6.0 and later as this breaks compilation with MinGW and older MSVC.
2014-09-30 22:17:44 +04:00
Vicente J. Botet Escriba
372f8fe10f Merge branch 'develop' of github.com:boostorg/thread into develop 2014-09-29 23:22:16 +02:00
Vicente J. Botet Escriba
e3c240df0a shared_future<R>::then() should be const. 2014-09-29 23:22:03 +02:00
Niall Douglas
748ea5164e Merge pull request #25 from MarcelRaad/patch-1
Fix GetTickCount return type
2014-09-29 19:18:38 +01:00
Vicente J. Botet Escriba
b44627f97d don't use std::queue with MSVC 11. 2014-09-29 00:19:35 +02:00
Vicente J. Botet Escriba
c8cd7d1d08 don't check for is_ready on all the futures when using when_wny. 2014-09-29 00:19:18 +02:00
Vicente J. Botet Escriba
f0d0c0551b rollback to not define BOOST_RESULT_OF_USE_DECLTYPE. 2014-09-29 00:00:49 +02:00
Vicente J. Botet Escriba
bb72eadbd8 Added validation of invalid inner future in wrap. 2014-09-29 00:00:06 +02:00
Marcel Raad
f52f32afda Fix GetTickCount return type
int as a return type results in a signed/unsigned mismatch warning with MSVC (although disabled by default), and it doesn't even compile with clang-cl if the definiton from the Windows header was included before.
2014-09-28 21:25:36 +02:00
Vicente J. Botet Escriba
b973e9b32e remove BOOST_THREAD_NO_CXX11_DECLTYPE_N3276. 2014-09-28 13:46:21 +02:00
Vicente J. Botet Escriba
1ffef9ed2d Add missing invoke.hpp include. 2014-09-28 13:40:16 +02:00
Vicente J. Botet Escriba
f24ea524bd Remove confusing may be remark and replace T by FutTypes. 2014-09-28 11:55:35 +02:00
Vicente J. Botet Escriba
4111471ba5 fix typo on file guard. 2014-09-28 09:19:42 +02:00
Vicente J. Botet Escriba
5e970b987e remove warning. 2014-09-28 00:34:15 +02:00
Vicente J. Botet Escriba
c7b5729cf3 Avoid the use fo invoke if not available, even if the semantics is not the same. 2014-09-27 19:59:25 +02:00
Vicente J. Botet Escriba
291ebded8e update changes and compliance with last fixed issues. 2014-09-27 19:58:17 +02:00
Vicente J. Botet Escriba
0c2c8ed3b8 Update doc with last modifications from Concurrent TS. 2014-09-27 19:57:33 +02:00
Vicente J. Botet Escriba
5294dfa149 Update doc with last modifications from Concurrent TS. 2014-09-27 16:45:39 +02:00
Vicente J. Botet Escriba
7f5dfb633d MSVC 10 doesn't provide std::is_copy_constructible. Make use of the boost version. 2014-09-26 06:48:40 +02:00
Vicente J. Botet Escriba
f381a7d591 Don't delete copy constructor when rvalue references are disabled. 2014-09-25 07:25:39 +02:00
Vicente J. Botet Escriba
aceabda609 try to avoid to unlock prematurely to see if this is the cause of the test_latch spourious failure. 2014-09-24 08:09:40 +02:00
Vicente J. Botet Escriba
dc4b619b57 Don't delete copy constructor when rvalue references are disabled. 2014-09-23 23:34:42 +02:00
Vicente J. Botet Escriba
abb3fc97e0 fix reported error. 2014-09-23 23:30:26 +02:00
Vicente J. Botet Escriba
ec6ae7b9b4 Take in account small durations. 2014-09-23 23:29:38 +02:00
Vicente J. Botet Escriba
8c5ba97d39 Don't use lambdas on test if not available. 2014-09-21 18:59:08 +02:00
Vicente J. Botet Escriba
617b979214 try a workaround with MSVC for error C3520: 'T' : parameter pack must be expanded in this context. 2014-09-21 18:58:41 +02:00
Vicente J. Botet Escriba
96667cfcce MSVC 10 doesn't provide std::is_move_constructible. Let as if all classes were movable in this case. 2014-09-21 18:58:23 +02:00
Vicente J. Botet Escriba
a981650ce9 cleanup. 2014-09-20 16:11:03 +02:00
Vicente J. Botet Escriba
00b25853b2 Added when_all/when_any iterators tests. 2014-09-20 16:05:19 +02:00
Vicente J. Botet Escriba
ef04ce8bce enable disabled test. 2014-09-20 14:53:06 +02:00
Vicente J. Botet Escriba
5091ad705f Added when_any/variadic_pass.cpp. 2014-09-20 14:37:47 +02:00
Vicente J. Botet Escriba
b77f802c47 variadic when_all/when_any must retur tuple instead of vector even when all the types are the same.. 2014-09-20 13:25:50 +02:00
Vicente J. Botet Escriba
da945436c1 avoid call to boost::get_system_time() when relative is true. 2014-09-14 21:51:01 +02:00
Vicente J. Botet Escriba
27befdf26f Added test for threads_specific_ptr<void>. 2014-09-14 21:49:31 +02:00
Vicente J. Botet Escriba
f73007910a replace unique_ptr<T> by optional<T> on shared_state when rvalue references are supported by the compiler, as optional<T> doesn't use Boost.Move. 2014-09-14 21:12:44 +02:00
Vicente J. Botet Escriba
8c3cfacf06 emulate template alias queue views. 2014-09-14 21:00:27 +02:00
Vicente J. Botet Escriba
7d4392e157 try to get rid of missing std::is_copy_constructible < gcc-4.5. 2014-09-14 09:09:59 +02:00
Vicente J. Botet Escriba
aff3f424a9 move sync_queue_closed to concurrent directory. 2014-09-13 22:17:19 +02:00
Vicente J. Botet Escriba
546ca909c4 try to avoid issue with < gcc-4.5 - error: 'is_copy_constructible' is not a member of 'std'. 2014-09-13 22:16:57 +02:00
Vicente J. Botet Escriba
7dac51706c Merge branch 'develop' 2014-09-12 23:40:30 +02:00
Vicente J. Botet Escriba
5ee0e27b5a add more try catch to trac the source of the error. 2014-09-12 22:50:56 +02:00
Vicente J. Botet Escriba
b4fd7fdeb1 fail test when exception cautch instead of rethrow it. 2014-09-11 13:33:43 +02:00
Vicente J. Botet Escriba
c75ea7db89 force the use of lambdas when available on multi_thread_pass test. 2014-09-11 13:32:11 +02:00
Vicente J. Botet Escriba
19294dc756 Change ref by ptr on queue fields of queue_views so that the default constructors can be generated on MSVC. 2014-09-11 13:30:48 +02:00
Vicente J. Botet Escriba
52a360775e cleanup. 2014-09-11 07:32:40 +02:00
Vicente J. Botet Escriba
c632b75db1 fix uninitialized variable. 2014-09-11 07:29:53 +02:00
Vicente J. Botet Escriba
11e4c950ac fix 10478 data race in boost/thread/future.hpp 2014-09-10 13:44:44 +02:00
Vicente J. Botet Escriba
8440e9a7d8 add tests on non_intettuption_point::sleep_... 2014-09-10 13:42:15 +02:00
Vicente J. Botet Escriba
02bc292c20 document non_intettuption_point::sleep_... 2014-09-10 13:41:11 +02:00
Vicente J. Botet Escriba
6d68bac44b fix move semantic issues on promise::set_value. Prepare the use of unique_ptr<T,D> to fix allocator issue. 2014-09-09 13:21:01 +02:00
Vicente J. Botet Escriba
5d0d128cab let movelib do the std adaptation. 2014-09-09 13:15:51 +02:00
Vicente J. Botet Escriba
ec542d3c8b remove commented code. 2014-09-08 05:49:10 +02:00
Vicente J. Botet Escriba
6e3216643b Remove future_traits<> as there are always an specialization. 2014-09-07 19:46:02 +02:00
Vicente J. Botet Escriba
016f5653cf Added when_all().then() tests. 2014-09-07 09:04:00 +02:00
Vicente J. Botet Escriba
ce46539183 Added when_all/when_any/queue_views tests. 2014-09-06 23:30:50 +02:00
Vicente J. Botet Escriba
e93035ce42 Added run_if_is_deferred to shared_future. 2014-09-06 23:30:36 +02:00
Vicente J. Botet Escriba
53a46593a8 make classes using BOOST_THREAD_MOVABLE_ONLY<T> satisfy is_copy_constructible<T>::value == false. 2014-09-06 14:20:59 +02:00
Vicente J. Botet Escriba
c2426b8fad fix missin common virtual function in queue_base_copyable_only. 2014-09-06 14:19:37 +02:00
Vicente J. Botet Escriba
7d841f6337 fix typo. 2014-09-06 14:18:36 +02:00
Vicente J. Botet Escriba
556bbde8a7 Implemented when_all/when_any when a tuple is returned. 2014-09-04 20:00:03 +02:00
Vicente J. Botet Escriba
a0c1462a6a merge from develop. 2014-09-02 21:41:59 +02:00
Vicente J. Botet Escriba
234df13faf remove BOOST_THREAD_USES_LOG. 2014-09-01 19:59:30 +02:00
Vicente J. Botet Escriba
24983f0bce Let the deferred tests be executed when BOOST_THREAD_PROVIDES_VARIADIC_THREAD is defined. 2014-08-31 20:05:43 +02:00
Vicente J. Botet Escriba
722997379b Added thread pool join function. 2014-08-31 18:16:49 +02:00
Vicente J. Botet Escriba
f36f5d6dbb Added more async deferred tests. 2014-08-31 18:16:14 +02:00
Vicente J. Botet Escriba
9ee1044f92 Merge branch 'develop' of github.com:boostorg/thread into develop 2014-08-31 09:00:04 +02:00
Vicente J. Botet Escriba
ebeb36646c Add test for issue #10340. 2014-08-31 08:59:40 +02:00
Vicente J. Botet Escriba
8ebf0e7f21 take in account ready tasks on when_all/when_any. 2014-08-31 08:57:27 +02:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
0dc2f69bc1 Fixed typo in just made merge for WinRT support. 2014-08-30 18:58:43 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
c3b549d947 Merge branch 'MSOpenTech-winrt2' into develop 2014-08-30 18:24:46 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
6552cf64b5 Fixed up WinRT support patch not compiling on WinRT. 2014-08-30 18:24:13 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
d5f335b8a4 Merge branch 'winrt2' of https://github.com/MSOpenTech/thread into MSOpenTech-winrt2 2014-08-30 17:16:17 +01:00
Vicente J. Botet Escriba
80591fb64d try to fix 10428 for uinque_ptr issues. 2014-08-30 17:57:12 +02:00
Vicente J. Botet Escriba
0543b522cb try to fix 10340. 2014-08-30 17:54:12 +02:00
Vicente J. Botet Escriba
3dbc5d0664 Added when_all/when_any documentation. 2014-08-30 13:43:42 +02:00
Vicente J. Botet Escriba
2d0272345b update doc cith generic executor and queue views. 2014-08-30 10:07:08 +02:00
Vicente J. Botet Escriba
f1a274b51c make it possible to have polymorphic queue copyable_only/movable_only/copyable_and_movable. 2014-08-29 21:06:15 +02:00
Vicente J. Botet Escriba
b7f1706ab8 Add test won when_all iterators for c++98 compilers. 2014-08-29 21:04:33 +02:00
Vicente J. Botet Escriba
f299fb8083 fix typo. 2014-08-29 12:51:42 +02:00
Vicente J. Botet Escriba
074dcbcbf5 make polymorphic queues move operations only available if C++11 RVALE supported. 2014-08-28 22:26:02 +02:00
Vicente J. Botet Escriba
af6f80a3c7 Added generic_executor_ref.cpp tp regression tests. 2014-08-27 13:36:58 +02:00
Vicente J. Botet Escriba
957253401f Try to fix invoker making it ComyConstructible and Movable. 2014-08-27 13:35:59 +02:00
Vicente J. Botet Escriba
3195253230 rollback last merge as it is breaking all the regression tests. 2014-08-27 00:16:19 +02:00
Vicente J. Botet Escriba
4336a7bbe3 Merge pull request #24 from MarcelRaad/patch-1
Use BOOST_THREAD_RV_REF for move constructors
2014-08-26 18:44:38 +02:00
Marcel Raad
3b75d6dabc Use BOOST_THREAD_RV_REF for move constructors
If BOOST_THREAD_FWD_REF is used, the copy constructor is re-declared. Tested with clang 3.4.
2014-08-26 10:17:26 +02:00
Vicente J. Botet Escriba
fc0d7e23b3 remove todo comments. 2014-08-25 17:17:50 +02:00
Vicente J. Botet Escriba
aeabda8d45 make use of move when a rvalue is used and make use of BOOST_THREAD_FWD_REF when a URef is used. 2014-08-24 22:48:06 +02:00
Vicente J. Botet Escriba
3bde7e103c Added virtual submit(work&). 2014-08-24 18:17:59 +02:00
Vicente J. Botet Escriba
ea0889485e Make use of BOOST_THREAD_COPYABLE_AND_MOVABLE and BOOST_THREAD_COPY_ASSIGN_REF when appropriated. 2014-08-24 18:16:28 +02:00
Vicente J. Botet Escriba
d4d46c64dd fix loop_executor run_queued_closures issue. 2014-08-23 19:14:21 +02:00
Vicente J. Botet Escriba
f3fa80c866 Added generic_executor_ref, queue_base and queue views, fix some issues in executors. 2014-08-23 18:29:47 +02:00
Vicente J. Botet Escriba
7e21f24991 Merge branch 'develop' of github.com:boostorg/thread into develop 2014-08-21 19:18:56 +02:00
Vicente J. Botet Escriba
2037a64c51 Avoid pedantic clang watnings. 2014-08-21 19:17:27 +02:00
Vicente J. Botet Escriba
8bfd1cea31 fix typo. 2014-08-21 19:16:41 +02:00
Niall Douglas
a26e7eb8c4 Merge pull request #22 from eldiener/master
For clang turn warnings to 'on' and remove '-pedantic' to avoid Boost PP...
2014-08-05 10:10:05 +01:00
Edward Diener
e47eba8751 For clang turn warnings to 'on' and remove '-pedantic' to avoid Boost PP warnings. 2014-08-04 19:30:29 -04:00
Eric Niebler
8aef8000d9 Merge branch 'master' into develop 2014-08-03 12:12:27 -07:00
Andrey Semashev
0b2a61bca0 Fixed compilation with gcc 4.6 in C++11 mode
The compiler considers invoke() call ambiguous when the function object is actually a function pointer. This caused compilation errors in Boost.Coroutine, which uses invoke() through call_once(). Also added missing includes.
2014-08-03 11:58:54 -07:00
Niall Douglas
78f1044c68 The previous mingw32 fix unfortunately broke mingw-w64, so that is now fixed too. 2014-08-02 21:38:31 +01:00
Niall Douglas
26042ca26a Fixed mingw32 compile breakage. 2014-08-02 18:56:08 +01:00
Vicente J. Botet Escriba
74132067ba prepare tss<void>. 2014-07-31 19:29:19 +02:00
Vicente J. Botet Escriba
c4d42e6b6c make use of wait_pull_front instead of pull_front. 2014-07-31 19:28:04 +02:00
Vicente J. Botet Escriba
59c504d5d8 Merge pull request #21 from Lastique/patch-3
Fixed compilation with gcc 4.6 in C++11 mode
2014-07-31 07:11:42 +02:00
Andrey Semashev
b81a838a43 Fixed compilation with gcc 4.6 in C++11 mode
The compiler considers invoke() call ambiguous when the function object is actually a function pointer. This caused compilation errors in Boost.Coroutine, which uses invoke() through call_once(). Also added missing includes.
2014-07-31 02:27:33 +04:00
Vicente J. Botet Escriba
c6e70226ea Merge branch 'develop' 2014-07-26 07:19:59 +02:00
Vicente J. Botet Escriba
5cdd807718 fix typo. 2014-07-26 07:19:28 +02:00
Vicente J. Botet Escriba
2a6948d74d comment scheduled_executor. 2014-07-26 06:07:30 +02:00
Steve Gates
a06dde3794 Merge branch 'develop' into winrt2
Conflicts:
	include/boost/thread/win32/thread_primitives.hpp
	src/win32/gettickcount64.cpp
2014-07-18 12:19:46 -07:00
Steve Gates
726a3faf19 Removing QueueUserAPC on Windows Runtime. 2014-07-17 10:49:09 -07:00
Niall Douglas
590a3d99b0 Merge pull request #20 from ned14/develop
Decrufted GetTicksCount64 patch. Fixed break of build on MSVC.
2014-07-11 10:27:27 +01:00
Steve Gates
c977c8d420 Qualifying some functions calls in thread_primitives.hpp to avoid potentially ambiguity. 2014-07-10 18:09:24 -07:00
Steve Gates
a1faacd7bb Fixing up copyrights that got reordered. 2014-07-09 16:43:48 -07:00
Steve Gates
866b78cbd0 Addressing more feedback:
Reverting disabling thread attributes for WinRT.
Created common GetSystemInfo/GetNativeSystemInfo function.
Fix this_thread get_id() bug on WinRT.
Enabled initializing the Windows Runtime in each test for execution. This
is not when using in Windows store/phone applications, just if a desktop
app.
2014-07-09 15:47:37 -07:00
Steve Gates
0861f81b05 Merge branch 'develop' of https://github.com/boostorg/thread into feedback 2014-07-08 14:53:47 -07:00
Steve Gates
6488028a22 Incorporating feedback: removed copyright, removed some ifdefs. 2014-07-08 14:53:39 -07:00
Vicente J. Botet Escriba
14dfe49c50 Merge branch 'develop' 2014-07-08 21:56:44 +02:00
Vicente J. Botet Escriba
08c4599fb6 Added inline for when_all() and when_any(). 2014-07-07 22:07:44 +02:00
Vicente J. Botet Escriba
ca14e6187d Merge branch 'develop' 2014-07-06 18:48:30 +02:00
Vicente J. Botet Escriba
f263c6014e fix wait_pull_front in case the queue is closed while empty. 2014-07-06 18:47:48 +02:00
Vicente J. Botet Escriba
9e962e12e2 Merge branch 'develop' 2014-07-06 11:48:55 +02:00
Vicente J. Botet Escriba
6e154d45a4 fix wait_pull_front issue introduced in previous commit and add more tests. 2014-07-06 11:05:51 +02:00
Vicente J. Botet Escriba
c54e519f72 disable traces. 2014-07-06 11:03:30 +02:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
5c61dced5e Replaced tabs with spaces. 2014-07-05 19:31:42 +01:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
8a7f927be9 Fixed breakage on MSVC. 2014-07-05 19:30:58 +01:00
Vicente J. Botet Escriba
6074487b73 Fix isse on sync_bounded_queue::wait_push_front and add tests. 2014-07-05 19:38:10 +02:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
04c53415fd Extracted the original GetTicksCount64 de-cruft patch and rebased on boostorg/thread:develop. 2014-07-05 16:38:17 +01:00
Vicente J. Botet Escriba
fe6daec2bc don't close the queue when an exception is throw, don't return empty on wait_pull_pull_front. 2014-07-05 14:57:37 +02:00
Vicente J. Botet Escriba
f75b2ca155 don't close the queue when an exception is throw, don't return empty on wait_pull_pull_front. 2014-07-05 14:57:10 +02:00
Vicente J. Botet Escriba
68be44ec06 Restore breaking change. 2014-07-05 10:34:22 +02:00
Vicente J. Botet Escriba
817591b87c protect the use of && when BOOST_NO_CXX11_RVALUE_REFERENCES is defined. 2014-07-04 08:07:57 +02:00
Vicente J. Botet Escriba
d7a3f124db Merge branch 'develop' 2014-07-03 07:10:04 +02:00
Vicente J. Botet Escriba
c6817aeb1c fall back to harware concurrency when physical concurrency doesn't works. 2014-07-03 07:08:07 +02:00
Steve Gates
9ceea9822f Enabling Boost.Thread to be used in the Windows Runtime.
This involves basically 3 changes:
1. Using __declspec(thread) instead of the Tls APIs.
2. Using Windows::System::Threading since Win32 Threading APIs aren't allowed.
3. Updating or replacing some banned APIs like WaitForSingleObject with WaitForSingleObjectEx.
2014-07-02 14:21:43 -07:00
Vicente J. Botet Escriba
c266790b8d Try to fix phisical_concurrency on PowerPC arch. 2014-06-29 23:48:18 +02:00
Vicente J. Botet Escriba
00ad9dddb9 Added nested type op_status. 2014-06-29 23:04:34 +02:00
Vicente J. Botet Escriba
21617e1acb Merge pull request #15 from Lastique/patch-2
Fix warnings about redefining a defined macro
2014-06-22 17:41:34 +02:00
Andrey Semashev
99ac322223 Fix warnings about redefining a defined macro
The warnings appear when a dependent project (e.g. Boost.Log tests and examples) builds with link=shared and defines BOOST_ALL_DYN_LINK macro. In this case BOOST_THREAD_USE_DLL is defined by both thread/build/Jamfile.v2 and boost/thread/detail/config.hpp. This commit makes sure that doesn't happen.
2014-06-22 19:13:01 +04:00
Vicente J. Botet Escriba
414fce4580 Merge branch 'develop' 2014-06-13 18:58:08 +02:00
Vicente J. Botet Escriba
fe195e776b make use of underlying_cast<int> insted of int cast. 2014-06-12 19:43:16 +02:00
Vicente J. Botet Escriba
8a6d3d68ce Merge pull request #14 from MarcelRaad/patch-1
Fix for BOOST_NO_CXX11_RVALUE_REFERENCES
2014-06-12 18:40:01 +02:00
Marcel Raad
3a5c926930 Fix for BOOST_NO_CXX11_RVALUE_REFERENCES
Fix compilation of future.hpp with BOOST_NO_CXX11_RVALUE_REFERENCES defined. Tested on clang and MSVC12.

BOOST_NO_CXX11_RVALUE_REFERENCES has to be defined if the compiler provides rvalue references, but the standard library doesn't provide std::move. Without these fixes, the deleted copy constructor is called.
2014-06-12 17:41:20 +02:00
Vicente J. Botet Escriba
685ee1506a Merge branch 'develop' 2014-06-10 17:42:23 +02:00
Vicente J. Botet Escriba
2062cebb54 Merge pull request #13 from danieljames/json-fix
Json fix
2014-06-10 07:29:01 +02:00
Daniel James
126030eb8c JSON fix. 2014-06-10 00:18:36 +01:00
Vicente J. Botet Escriba
ac1b9653f3 Merge branch 'develop' 2014-06-09 17:55:57 +02:00
Vicente J. Botet Escriba
54ee07e745 Make use of core files. 2014-06-09 17:35:00 +02:00
Vicente J. Botet Escriba
ca298c2c86 Don't use atomic<thread::id> and so don't use testable_mutex. 2014-06-09 15:41:42 +02:00
Vicente J. Botet Escriba
4def87448e Merge pull request #12 from Lastique/patch-3
Silence warnings about unused variables.
2014-06-09 15:07:48 +02:00
Vicente J. Botet Escriba
5719ea9e9f Added meta/libraries.json. 2014-06-09 14:07:54 +02:00
Vicente J. Botet Escriba
6583d87c92 Added README.md. 2014-06-09 14:05:57 +02:00
Vicente J. Botet Escriba
fcf7a1811e make use of underlying_cast<int> when casting from an enum class. 2014-06-09 14:04:11 +02:00
Andrey Semashev
d8f628ae65 Silence warnings about unused variables. 2014-06-09 15:20:12 +04:00
Vicente J. Botet Escriba
0bd10b7244 Merge branch 'develop' 2014-06-08 12:11:31 +02:00
Vicente J. Botet Escriba
24635c588f Removed incomplete file. 2014-06-04 13:04:59 +02:00
Vicente J. Botet Escriba
4f8106c00e remove dependency on Optional. 2014-06-04 08:21:08 +02:00
Vicente J. Botet Escriba
3c4f1ea365 remove dependency on MPL. 2014-06-04 08:20:28 +02:00
Vicente J. Botet Escriba
b5a50ab443 remove unused param warning. 2014-06-04 08:19:34 +02:00
Vicente J. Botet Escriba
cb8a4a27bb Throw if malloc fails. 2014-05-31 18:19:43 +02:00
Vicente J. Botet Escriba
8c0640e5be Fix typo. 2014-05-21 20:07:53 +02:00
Vicente J. Botet Escriba
f807a678e0 Merge branch 'develop' of github.com:boostorg/thread into develop 2014-05-21 19:52:01 +02:00
Vicente J. Botet Escriba
49a1779d7f Merge pull request #10 from kylelutz/variadic-wait-for
Variadic wait functions
2014-05-21 19:48:04 +02:00
Kyle Lutz
d3d2ad2390 Add variadic wait_for_all() and wait_for_any() functions 2014-05-20 22:49:44 -07:00
Vicente J. Botet Escriba
abf844f50e fix #10008. 2014-05-08 01:30:23 +02:00
Vicente J. Botet Escriba
4d52ef0740 Comment no more existing functions. 2014-04-28 18:41:53 +02:00
Vicente J. Botet Escriba
40620e3d4b Merge branch 'develop' 2014-04-27 15:45:16 +02:00
Vicente J. Botet Escriba
c3ab21a7ba comment mingw toolset flags - #3967. 2014-04-19 13:04:15 +02:00
Vicente J. Botet Escriba
c3002edc54 cleanup. 2014-03-30 17:29:06 +02:00
Vicente J. Botet Escriba
100bb706d6 Merge branch 'develop' 2014-03-17 19:55:06 +01:00
Vicente J. Botet Escriba
de6a4df3a8 Merge pull request #7 from kylelutz/fix-futures-doc
Thanks for the signaling this typo.
2014-03-13 08:46:13 +01:00
Kyle Lutz
9669830a86 Fix documentation for shared_future example 2014-03-12 20:35:27 -07:00
Vicente J. Botet Escriba
2937171413 Added asynchronous executors doc. 2014-03-12 00:04:03 +01:00
Vicente J. Botet Escriba
dd0bfdd7ce Update compliance to standard proposals. 2014-03-12 00:03:19 +01:00
Vicente J. Botet Escriba
89e340b177 Update last fixed bugs. 2014-03-12 00:02:44 +01:00
Vicente J. Botet Escriba
c744899e45 Complete sync queues reference doc. 2014-03-12 00:02:12 +01:00
Vicente J. Botet Escriba
0a4af0c5ed Merge branch 'develop' 2014-03-10 19:28:02 +01:00
Vicente J. Botet Escriba
e6eb24d4a9 Merge pull request #6 from Lastique/patch-1
Fix compilation on Windows
2014-03-10 18:55:19 +01:00
Andrey Semashev
0d10e282fa Fix compilation on Windows
Corrected is_special method name.
2014-03-10 19:43:46 +03:00
Vicente J. Botet Escriba
e8181da6d4 Merge branch 'develop' 2014-03-09 14:47:51 +01:00
Vicente J. Botet Escriba
68dc454a66 Take in account pos_infinity. 2014-03-09 14:42:50 +01:00
Vicente J. Botet Escriba
0e0ee99c61 Added BOOST_THREAD_DECL to GetTickCount64. 2014-03-04 00:29:39 +01:00
Vicente J. Botet Escriba
f747d79c5b comment redefinition of ticks_type. 2014-03-02 12:46:56 +01:00
Vicente J. Botet Escriba
73fbc520e8 extract async executor test. 2014-03-01 08:38:08 +01:00
Vicente J. Botet Escriba
7d4f485ade Added test for #9303. 2014-03-01 08:32:53 +01:00
Vicente J. Botet Escriba
143adde27d pull patch for #8070. 2014-02-27 07:47:20 +01:00
Vicente J. Botet Escriba
a7400061c6 added test for #9711. 2014-02-26 22:09:15 +01:00
Vicente J. Botet Escriba
d2a65d2427 fix #9711. 2014-02-26 22:08:09 +01:00
Vicente J. Botet Escriba
82379f83a8 fix #9673. 2014-02-26 18:48:02 +01:00
Vicente J. Botet Escriba
cc29295986 Merge branch 'develop' 2014-02-21 13:37:06 +01:00
Vicente J. Botet Escriba
9d1c957625 change check time to 500 ms. 2014-02-21 13:36:33 +01:00
Vicente J. Botet Escriba
1dbf7028fe Try to workaround some issues with MSVC lambdas. 2014-02-21 10:52:18 +01:00
Vicente J. Botet Escriba
0bba5e630e Merge branch 'develop' 2014-02-16 23:39:00 +01:00
Vicente J. Botet Escriba
84c30313a2 Start invoker_ret. 2014-02-16 23:34:52 +01:00
Vicente J. Botet Escriba
54646e9959 Added sleep_for/until with no interruption point. 2014-02-16 23:33:03 +01:00
Vicente J. Botet Escriba
3f5823f50a Add parallel_quick_sort example. 2014-02-16 17:25:49 +01:00
Vicente J. Botet Escriba
e1636bdbd5 Take care of #9618: try_join_for(ms(1)). 2014-02-16 10:53:07 +01:00
Vicente J. Botet Escriba
750c849b0f merge from develop for 1.56. 2014-02-15 16:08:32 +01:00
Vicente J. Botet Escriba
0a05db8399 rename async_func.hpp by invoker.hpp. 2014-02-11 22:39:55 +01:00
Vicente J. Botet Escriba
1d7da085ea rename async_func.hpp by invoker.hpp. 2014-02-10 07:42:28 +01:00
Vicente J. Botet Escriba
75236fe3ae rename async_func by invoker. 2014-02-09 16:53:19 +01:00
Vicente J. Botet Escriba
80634ee51e Added with_lock_guard example. 2014-02-09 04:01:53 +01:00
Vicente J. Botet Escriba
b1ac899f23 Pulled with_lock_guard patch. 2014-02-09 03:42:39 +01:00
Vicente J. Botet Escriba
aa37de7aad remove traces on tests. 2014-02-08 17:48:54 +01:00
Vicente J. Botet Escriba
9d527bebe0 fix typo on scoped_thread tutorial. 2014-02-08 17:47:28 +01:00
Vicente J. Botet Escriba
f7c18c55bb remove availability of deprecated functions. 2014-02-08 17:46:34 +01:00
Vicente J. Botet Escriba
1a2197c7f9 Added exceptional_ptr documentation. 2014-02-08 17:45:41 +01:00
Vicente J. Botet Escriba
4a54ac0331 make functions that must be private private, e.g. as start_thread. 2014-02-08 17:43:23 +01:00
Vicente J. Botet Escriba
c6593d87b0 clarify thread destructor and move constructor semantics. 2014-02-08 17:42:28 +01:00
Vicente J. Botet Escriba
51e49c69b5 refactor elapsed time check and fix bad uses of base_type. in csbl::unique_ptr. 2014-02-08 16:28:02 +01:00
Vicente J. Botet Escriba
ab2a180de5 Added test for async_func and fixed a some issues. 2014-02-08 07:58:39 +01:00
Vicente J. Botet Escriba
3772a8294b Format/indent file. 2014-02-07 07:32:34 +01:00
Vicente J. Botet Escriba
155ccfffbe fix copyright. 2014-02-03 18:57:10 +01:00
Vicente J. Botet Escriba
bfa0ccee88 Added BOOST_RESULT_OF_USE_DECLTYPE on async test. 2014-02-03 18:33:01 +01:00
Vicente J. Botet Escriba
980772d514 Added make_ready_no_decay_future and remove the use of asynch on make_future test. 2014-02-03 18:31:43 +01:00
Vicente J. Botet Escriba
94b27db991 move when mawros to config.hpp file. 2014-02-03 18:30:08 +01:00
Vicente J. Botet Escriba
0a58445b63 comment #error 2014-02-02 08:47:56 +01:00
Vicente J. Botet Escriba
f02e25e4e7 Add BOOST_RESULT_OF_USE_DECLTYPE. 2014-02-02 08:45:29 +01:00
Vicente J. Botet Escriba
acb117b5a9 Added lvalue test to call_once. 2014-02-02 08:38:40 +01:00
Vicente J. Botet Escriba
8682f7cb48 Added some test to internal invoke function add the associated fixes. 2014-02-02 08:13:58 +01:00
Vicente J. Botet Escriba
4503c0e1da comment the warning as it generates an error. 2014-02-01 21:56:22 +01:00
Vicente J. Botet Escriba
dc3397c452 Added parallel_acumulate example. 2014-01-28 23:14:43 +01:00
Vicente J. Botet Escriba
af7fde5eae Added test async with a member function. 2014-01-28 23:12:29 +01:00
Vicente J. Botet Escriba
36bc3c0523 Added 2 arguments async executor. 2014-01-28 23:08:07 +01:00
Vicente J. Botet Escriba
0218cb90b3 fix typo issues on invoke. 2014-01-28 23:01:41 +01:00
Vicente J. Botet Escriba
f4d4c16294 try to fix compiler error while using std::get instead of csbl::get 2014-01-27 22:30:48 +01:00
Vicente J. Botet Escriba
85d22a8d93 Added exceptional_ptr and adapt futures to be implicitly convertible from exceptional_ptr. 2014-01-26 17:55:09 +01:00
Vicente J. Botet Escriba
7eb67443dd Added exceptional_ptr and adapt futures to be implicitly convertible from exceptional_ptr. 2014-01-26 17:53:49 +01:00
Vicente J. Botet Escriba
4308e0ec24 Added make_exceptional_future. 2014-01-26 09:19:31 +01:00
Vicente J. Botet Escriba
ac9497dec9 Try to solve some issues with invoke on MSVC. 2014-01-26 09:18:34 +01:00
Vicente J. Botet Escriba
8fec35f444 Update mutex destructor to see if the assertion message is better. 2014-01-26 09:15:12 +01:00
Vicente J. Botet Escriba
7b3fa08503 make shared_state_nullary_task copyable and movable and avoid msvc default generation. 2014-01-20 23:02:48 +01:00
Vicente J. Botet Escriba
a2e1e80343 Try to see if giving the addres solves the MSVC compiler issue. 2014-01-20 23:01:23 +01:00
Vicente J. Botet Escriba
690feeb9ba indent and comment #if. 2014-01-19 07:56:57 +01:00
Vicente J. Botet Escriba
5d76ab52e7 reorder async() conditional compilation variants to factor more code. 2014-01-19 07:52:38 +01:00
Vicente J. Botet Escriba
cb845f19e4 Fix issues with future::async and disable the code when BOOST_NO_CXX11_DECLTYPE_N3276 is defined as it is bugged. 2014-01-18 15:27:03 +01:00
Vicente J. Botet Escriba
2886e985b4 cleanup comments. 2014-01-16 23:58:37 +01:00
Vicente J. Botet Escriba
f4d0ecbab5 Added at thread entry callback on thread pool. 2014-01-13 22:51:57 +01:00
Vicente J. Botet Escriba
d187732946 Added minimal inline and thread test. 2014-01-13 22:32:30 +01:00
Vicente J. Botet Escriba
1fc78c7ceb Added inline and thread executors. 2014-01-13 22:16:09 +01:00
Vicente J. Botet Escriba
5c18d92a5f Make work public. 2014-01-13 22:10:34 +01:00
Vicente J. Botet Escriba
06325961ef Make work public. 2014-01-13 22:09:43 +01:00
Vicente J. Botet Escriba
10b283e03a Added missing iomanip include. 2014-01-13 22:08:20 +01:00
Vicente J. Botet Escriba
6ab71dc057 executor_adaptor<serial_executor> a(b) doesn't compiles on C++03. 2014-01-12 18:28:24 +01:00
Vicente J. Botet Escriba
47be5228b1 fix typo on try_push_back. 2014-01-12 18:26:46 +01:00
Vicente J. Botet Escriba
6c5a6e4330 Reorganized executors on its own directory adding serial_executor and renamed thread_pool by basic_thread_pool and user_scheduler by loop_scheduler. 2014-01-12 17:52:27 +01:00
Vicente J. Botet Escriba
326842cc7f Fix #9335 Missing exception safety might result in crash 2014-01-11 21:19:05 +01:00
Vicente J. Botet Escriba
9f592860cd Update sync queues closed operations 2014-01-11 18:57:44 +01:00
Vicente J. Botet Escriba
4148842426 Apply changed from #9471 Synchronization documentation nits and prepare changes notes for Boost 1.56
modified:   changes.qbk
	modified:   external_locking.qbk
	modified:   internal_locking.qbk
	modified:   thread.qbk
2014-01-11 12:44:28 +01:00
Vicente J. Botet Escriba
7edae6614b Thread: add exception trace.
[SVN r86774]
2013-11-19 22:09:40 +00:00
Vicente J. Botet Escriba
2554065a91 Thread: update doc with last features changes.
[SVN r86773]
2013-11-19 22:08:29 +00:00
Vicente J. Botet Escriba
74bb7d6b29 Thread: for explicit constructor for nullary_function.
[SVN r86772]
2013-11-19 22:00:56 +00:00
Vicente J. Botet Escriba
fbfda71555 Thread: Allows to force the use of boost libraries on csbl.
[SVN r86771]
2013-11-19 21:58:59 +00:00
Vicente J. Botet Escriba
f3a66f76e0 Thread: merge from trunk for 1.56.
[SVN r86770]
2013-11-19 21:58:34 +00:00
Vicente J. Botet Escriba
19346e1817 Thread: improve async_func to try to solve msvc issue with executor.
[SVN r86744]
2013-11-17 23:44:45 +00:00
Vicente J. Botet Escriba
5753026ceb Thread: increase the number of cycles of the failing tests.
[SVN r86732]
2013-11-17 00:32:28 +00:00
Vicente J. Botet Escriba
f6edd7cace Thread: use PP only if MSVC not defined, until I can debug it.
[SVN r86714]
2013-11-15 19:51:40 +00:00
Vicente J. Botet Escriba
126ed2428b Thread: try to remove warning C4520: 'boost::executor_adaptor<boost::thread_pool>' : multiple default constructors specified.
[SVN r86698]
2013-11-14 18:53:51 +00:00
Vicente J. Botet Escriba
fd631e2794 Thread: remove BOOST_THREAD_MAX_ARGS_P1.
[SVN r86697]
2013-11-14 17:56:07 +00:00
Vicente J. Botet Escriba
44f9a2f4ad Thread: merge dummy replacement to fix #9341.
[SVN r86658]
2013-11-12 18:35:19 +00:00
Vicente J. Botet Escriba
8665c5d510 Thread: merge missing include string.
[SVN r86657]
2013-11-12 18:33:52 +00:00
Vicente J. Botet Escriba
e1d6baddd6 Thread: merge missing thread move constructor noexcept.
[SVN r86656]
2013-11-12 18:32:37 +00:00
Vicente J. Botet Escriba
9287a29c9d Thread: Adding pp variadic to asyn_func and fix some typos.
[SVN r86629]
2013-11-11 23:00:37 +00:00
Vicente J. Botet Escriba
5c0cecaaf8 Thread: add _back/_front using queue_op_status interface to sync queues and update the depending classes thread_pool and user_scheduler; Simplfy some test to isolate the errors on msvc-12.
[SVN r86616]
2013-11-11 10:43:15 +00:00
Vicente J. Botet Escriba
713f5a449c Thread: Added missing include.
[SVN r86599]
2013-11-09 15:26:49 +00:00
Vicente J. Botet Escriba
b336427571 Thread: try to fix error on mscv-12 when scoped_thread uses private dummy class with enable_if.
[SVN r86595]
2013-11-09 11:50:21 +00:00
Vicente J. Botet Escriba
2a16b649ad Thread: Added caller_context.hpp; Change executor by Executor template parameter in async; update the number of time the failing tests are run to catch all the compilers.
[SVN r86586]
2013-11-08 17:51:39 +00:00
Vicente J. Botet Escriba
3723cedcab Thread: Added user_scheduler (loop_executor).
[SVN r86570]
2013-11-06 06:37:46 +00:00
Vicente J. Botet Escriba
3ad582222c Thread: added test for #9303.
[SVN r86569]
2013-11-05 23:08:13 +00:00
Vicente J. Botet Escriba
c9a33b8668 Thread: avoid thread ambiguity on vacpp tester.
[SVN r86568]
2013-11-05 23:07:28 +00:00
Vicente J. Botet Escriba
88880770d3 Thread: merge [86540] to fix #9319.
[SVN r86552]
2013-11-03 20:43:42 +00:00
Vicente J. Botet Escriba
9138a2ae92 Thread: Added missing variadic constructor for task_shared_state.
[SVN r86548]
2013-11-03 16:17:23 +00:00
Vicente J. Botet Escriba
d558de7811 Thread: added new/old tickets tests for regression purposes.
[SVN r86545]
2013-11-02 12:58:03 +00:00
Vicente J. Botet Escriba
19290fddf9 Thread: manage system::errc as it was an real enum class, so no implicitly convertible to an int.
[SVN r86544]
2013-11-02 09:58:33 +00:00
Vicente J. Botet Escriba
2ac967d1dc Thread: try to avoid compile error with msvc.12 or atleast remove warning C4512.
[SVN r86543]
2013-11-02 09:56:20 +00:00
Vicente J. Botet Escriba
6e81db4172 Thread: try to avoid compile error with msvc.12.
[SVN r86542]
2013-11-02 09:54:13 +00:00
Vicente J. Botet Escriba
3a68a63478 Thread: unlock around the calls to continuations oe deferred future executions.
[SVN r86540]
2013-11-01 21:08:00 +00:00
Vicente J. Botet Escriba
7875edd234 Thread: make use of csbl to make the code more readable and to ensure that it interact well with the std.
[SVN r86504]
2013-10-28 20:08:39 +00:00
Vicente J. Botet Escriba
2be0b4f8fd Thread: added missing boost/tuple/tuple.hpp file.
[SVN r86498]
2013-10-28 10:34:51 +00:00
Vicente J. Botet Escriba
67528fc9af Thread: fix thread move constructor noexecpt.
[SVN r86493]
2013-10-28 02:31:55 +00:00
Vicente J. Botet Escriba
4da1e9dca1 Thread: cleanup replacing some macros by the types imported on csbl namespace comming from std or boost. Cleanup work type ussage.
[SVN r86471]
2013-10-26 23:35:40 +00:00
Vicente J. Botet Escriba
d8c9be3449 Thread: fix change of BOOST_THREAD_VECTOR to boost::csbl::vector.
[SVN r86467]
2013-10-26 22:47:02 +00:00
Vicente J. Botet Escriba
f02390a804 Thread: fix double definition of i in test.
[SVN r86466]
2013-10-26 22:43:12 +00:00
Vicente J. Botet Escriba
955b207c05 Thread: Added csbl (Common Std Boost Library) files, which allows to use on the csbl namespace eother a std or a boost file, e.g. tuple, vector, functional.
[SVN r86453]
2013-10-26 15:07:34 +00:00
Vicente J. Botet Escriba
c17f5d3fc7 Thread: merge update history for limitations.
[SVN r86449]
2013-10-26 12:39:50 +00:00
Vicente J. Botet Escriba
8685c32d18 Thread: update history with know limitations.
[SVN r86446]
2013-10-26 11:59:52 +00:00
Vicente J. Botet Escriba
f51e8c812a Thread: Add a loop to catch more quickly the multiple bugs on boost::future experimental features and see which tester are failing.
[SVN r86444]
2013-10-26 11:22:14 +00:00
Vicente J. Botet Escriba
51aff0fb00 Thread: Adapt barrier to new nullary_function.
[SVN r86443]
2013-10-26 10:23:00 +00:00
Vicente J. Botet Escriba
bfe7af29bc Thread: adapt thread_pool and executor to the new nullary_function work.
[SVN r86442]
2013-10-26 10:21:27 +00:00
Vicente J. Botet Escriba
4681104b33 Thread: Added a portable copyable/movable thread_pool/executor work.
[SVN r86441]
2013-10-26 10:20:13 +00:00
Vicente J. Botet Escriba
d602f44af6 Thread: Added a portable copyable/movable nullary_function functor.
[SVN r86440]
2013-10-26 10:20:02 +00:00
Vicente J. Botet Escriba
dc55945760 Thread: Add BOOST_THREAD_RV when accessing a BOOST_THREAD_RV_REF to be portable.
[SVN r86439]
2013-10-26 10:19:38 +00:00
Vicente J. Botet Escriba
f7f0347780 Thread: first steps toward async(executor&, f).
[SVN r86327]
2013-10-16 06:15:51 +00:00
Vicente J. Botet Escriba
d6c4be0cd0 Thread: add thread_pool reserv for worker threads.
[SVN r86291]
2013-10-13 13:15:05 +00:00
Vicente J. Botet Escriba
e146febd70 Thread: Added future::when_all/when_any (async vector version) for C++11 compilers.
[SVN r86290]
2013-10-13 13:08:29 +00:00
Vicente J. Botet Escriba
67ca45ed83 Thread: Added synchronized_value const test.
[SVN r86283]
2013-10-13 10:13:10 +00:00
Vicente J. Botet Escriba
cad6f2b9a6 Thread: Add Copyright.
[SVN r86282]
2013-10-13 10:11:06 +00:00
Tim Blechmann
7756df2ce0 thread: physical_concurrency - avoid c++03-style vector::data
[SVN r86226]
2013-10-10 14:53:37 +00:00
Tim Blechmann
ae831efe08 thread: physical_concurrency - work around getline issue in libc++
[SVN r86216]
2013-10-09 15:25:31 +00:00
Tim Blechmann
fc65611e82 Revert "Thread: provide physical concurrency conditional until it no regression is introduced."
This reverts commit 271ba281aecd5c556b2b863a9f05a8066e717854.

[SVN r86215]
2013-10-09 15:24:58 +00:00
Vicente J. Botet Escriba
8c6dcb9709 Thread: fix some issues with double definition of shared_state_base and avoid ambiguity of disable_if with Boost.Test.
[SVN r86202]
2013-10-08 17:09:38 +00:00
Vicente J. Botet Escriba
67afa35c49 Thread: try to fix issue with double definition of shared_state_base.
[SVN r86162]
2013-10-04 20:07:03 +00:00
Vicente J. Botet Escriba
63d9ae2b29 Thread: Added a polymorphic executor and an executor_adaptor.
[SVN r86161]
2013-10-04 20:05:26 +00:00
Vicente J. Botet Escriba
08aa0d2fb6 Thread: use boost::disable_if instead of disable_if to avoid ambiguity.
[SVN r86140]
2013-10-02 22:45:23 +00:00
Stephen Kelly
3c8334f8c4 Thread: Remove obsolete GCC version check.
[SVN r86117]
2013-10-01 08:48:07 +00:00
Vicente J. Botet Escriba
0e2c8ed9e3 Thread: ensure that the thread is joined on the future destructor created by future<T>::then().
[SVN r86010]
2013-09-29 19:10:11 +00:00
Vicente J. Botet Escriba
5bfa7cff41 Thread: update history.
[SVN r86005]
2013-09-29 16:10:56 +00:00
Vicente J. Botet Escriba
e3a1498355 Thread: provide physical_concurrency conditionally.
[SVN r86002]
2013-09-29 14:41:01 +00:00
Vicente J. Botet Escriba
6fab117c17 Thread: future::then should join the thread before destruction.
[SVN r85962]
2013-09-26 14:47:24 +00:00
Vicente J. Botet Escriba
4a63d4992c Thread: provide physical concurrency conditional until it no regression is introduced.
[SVN r85926]
2013-09-26 06:54:33 +00:00
Tim Blechmann
04e3d918fb thread: implement physical_concurrency
[SVN r85864]
2013-09-24 06:41:24 +00:00
Vicente J. Botet Escriba
0073516f0a Thread: added missing function wrapper.
[SVN r85863]
2013-09-24 05:35:11 +00:00
Vicente J. Botet Escriba
89de3dcf4f Thread: make it possible to use non default constructible types in sync_queue, but sync_bounded_queue requires it yet.
[SVN r85861]
2013-09-23 21:40:08 +00:00
Vicente J. Botet Escriba
47f40f991f Thread: added first thread_pool.
[SVN r85855]
2013-09-23 16:45:00 +00:00
Vicente J. Botet Escriba
8b351fe473 Thread: fix some move semantic issues on sync_queue and sync_bounded_queue and add tests.
[SVN r85854]
2013-09-23 16:44:26 +00:00
Vicente J. Botet Escriba
2da4e8c29e Thread: add a test on get_exception_ptr.
[SVN r85843]
2013-09-22 23:35:04 +00:00
Vicente J. Botet Escriba
8dce737911 Thread: fix non-copyable issues with intel compiler.
[SVN r85842]
2013-09-22 23:33:52 +00:00
Vicente J. Botet Escriba
24f1e620e8 Thread: fix some move issues on sync_queue.
[SVN r85841]
2013-09-22 22:23:58 +00:00
Vicente J. Botet Escriba
ed6459ecd2 Thread: make code uniform heap_new/heap_delete pairwise.
[SVN r85840]
2013-09-22 22:22:08 +00:00
Andrey Semashev
3a7f0b1e78 Merged changes from trunk.
[SVN r85818]
2013-09-22 09:57:15 +00:00
Vicente J. Botet Escriba
8f06153f46 Thread: merge from trunk to fix 8070 and possibly 7461.
[SVN r85815]
2013-09-21 20:45:06 +00:00
Vicente J. Botet Escriba
858816b2d2 Thread: add detail:: to access detail::win32::GetTickCount64().
[SVN r85772]
2013-09-18 10:58:46 +00:00
Vicente J. Botet Escriba
4bc70444a4 Thread: try to fix SIGSEGV on win32 issue #7666.
[SVN r85734]
2013-09-17 21:17:02 +00:00
Vicente J. Botet Escriba
fcc027369f Thread: try to fix win32 condition_variable issue #7461.
[SVN r85733]
2013-09-17 21:01:05 +00:00
Vicente J. Botet Escriba
5c78582794 Thread: refactor make_ready_at_thread_exit + inhibit at_thread_exit functions from external threads.
[SVN r85732]
2013-09-17 20:57:46 +00:00
Vicente J. Botet Escriba
7f479a1dec Thread: Added test for tickets.
[SVN r85729]
2013-09-17 19:32:03 +00:00
Vicente J. Botet Escriba
4f2a7b2256 Thread: make use of explicit noncopyable constructor to avoid compile error with Intel compiler.
[SVN r85728]
2013-09-17 19:25:18 +00:00
Vicente J. Botet Escriba
5c88e6ce61 Thread: patch for #8070 to make use of GetTickCount64 when available.
[SVN r85714]
2013-09-16 19:43:37 +00:00
Vicente J. Botet Escriba
650e374492 Thread: Added ostream_buffer.
[SVN r85709]
2013-09-16 17:24:30 +00:00
Vicente J. Botet Escriba
6319080ef2 Thread: add test for get_exception_ptr.
[SVN r85708]
2013-09-16 17:15:05 +00:00
Vicente J. Botet Escriba
3ac48bdd65 Thread: patch for #8070 to make use of GetTickCount64 when available.
[SVN r85701]
2013-09-16 16:55:21 +00:00
Vicente J. Botet Escriba
c3c8ada97d Thread: replace TABS.
[SVN r85677]
2013-09-15 16:13:47 +00:00
Vicente J. Botet Escriba
325d8cf5ca Thread: merge atomic linked conditionaly + future:get_exception_ptr.
[SVN r85666]
2013-09-14 14:22:45 +00:00
Vicente J. Botet Escriba
134c323958 Thread: merge scoped_thread constr + condition_variable timed wait issues on windows + doc typos.
[SVN r85663]
2013-09-13 19:01:48 +00:00
Vicente J. Botet Escriba
fd5dd0c2ed Thread: added future<>::get_exception_ptr().
[SVN r85644]
2013-09-10 19:40:14 +00:00
Vicente J. Botet Escriba
4a83aa58ed Thread: add workaround for non compliants compilers on scoped_thread constructor.
[SVN r85643]
2013-09-10 18:55:52 +00:00
Vicente J. Botet Escriba
7d96aa625c Thread: update doc with history.
[SVN r85623]
2013-09-09 17:37:54 +00:00
Vicente J. Botet Escriba
5520763a73 Thread fix #8943.
[SVN r85622]
2013-09-09 17:04:15 +00:00
Vicente J. Botet Escriba
ad010e0647 Thread: fix #8417.
[SVN r85621]
2013-09-09 16:57:32 +00:00
Vicente J. Botet Escriba
d57a4c6565 Thread: link with boost_atomic conditionaly.
[SVN r85616]
2013-09-08 22:20:48 +00:00
Vicente J. Botet Escriba
73f5c060ca Thread: merge from trunk upgrade_to_unique_lock::mutex() + doc typos + BOOST_THREAD_USES_ATOMIC doc + synchronized _value call + rename wait_until params.
[SVN r85603]
2013-09-08 09:50:12 +00:00
Vicente J. Botet Escriba
c67e39f126 Thread: protect condition_variable/_any wait_for and wait_until from malicious input.
[SVN r85592]
2013-09-07 12:11:44 +00:00
Vicente J. Botet Escriba
5a3c301582 Thread: protect condition_variable/_any wait_for and wait_until from malicious input.
[SVN r85591]
2013-09-07 12:11:18 +00:00
Vicente J. Botet Escriba
dc5a8a9c4e Thread: try to handle with not needed definition of uintptr_t #8817.
[SVN r85540]
2013-09-01 07:25:56 +00:00
Vicente J. Botet Escriba
1e49343ff4 Thread: try to handle with call_once intel issue #8943.
[SVN r85539]
2013-09-01 07:22:21 +00:00
Vicente J. Botet Escriba
93d1855e64 Thread: fix scoped_thread variadic constructor.
[SVN r85494]
2013-08-27 22:37:15 +00:00
Vicente J. Botet Escriba
a39dd7e8b3 Thread: avoid conflict with thread symbol.
[SVN r85493]
2013-08-27 22:35:21 +00:00
Vicente J. Botet Escriba
7e5cb92bab Thread: fix some typos in doc.
[SVN r85492]
2013-08-27 22:31:32 +00:00
Vicente J. Botet Escriba
62cf0f86f6 Thread: fix more typos in doc.
[SVN r85485]
2013-08-27 11:32:24 +00:00
Vicente J. Botet Escriba
c12e07754a Thread: link with boost_chrono and boost_atomic independently of the platform.
[SVN r85464]
2013-08-25 15:13:17 +00:00
Vicente J. Botet Escriba
cbc4266774 Thread: rename wait_until parameter to avoid shadow with member function.
[SVN r85463]
2013-08-25 15:09:12 +00:00
Vicente J. Botet Escriba
3a038d33e5 Thread: rename check by cgeck_counter to avoid conflict with macro.
[SVN r85462]
2013-08-25 15:08:08 +00:00
Vicente J. Botet Escriba
51ba4be998 Thread: fix type and add BOOST_THREAD_USE_ATOMIC macro doc.
[SVN r85432]
2013-08-22 22:11:48 +00:00
Vicente J. Botet Escriba
2d50af8481 Thread: Added synchronized_value operator() to synchronize around a function call.
[SVN r85306]
2013-08-11 20:33:47 +00:00
Vicente J. Botet Escriba
3fb971386a Thread: merge from trunk last updates since 1.54.
[SVN r85200]
2013-08-03 16:04:39 +00:00
Vicente J. Botet Escriba
e438c98070 Thread: Add mutex() to upgrade_to_unique_lock (#8891).
[SVN r85195]
2013-08-03 07:47:18 +00:00
Vicente J. Botet Escriba
1e2a76de47 Thread: apply pathc for #8931.
[SVN r85194]
2013-08-03 07:44:15 +00:00
Vicente J. Botet Escriba
34311a60fa Thread: update doc for latches, future continuations.
[SVN r84980]
2013-07-07 20:50:14 +00:00
Vicente J. Botet Escriba
794d54a65c Thread: fix issue with continuation's future parameter which must taken by value.
[SVN r84979]
2013-07-07 20:44:02 +00:00
Vicente J. Botet Escriba
d759dd2dba Thread: fix issue with continuation's future parameter which must taken by value.
[SVN r84978]
2013-07-07 20:36:05 +00:00
Hartmut Kaiser
fe46155997 Getting rid of 64bit warning generated by VS2012
[SVN r84960]
2013-07-06 18:51:54 +00:00
Vicente J. Botet Escriba
cacb5b19a6 Thread: fix issue with future<>::then() when th efuture was not created with async.
[SVN r84955]
2013-07-04 21:44:25 +00:00
Vicente J. Botet Escriba
30803a38b2 Thread: Added assertion on testable_mutex lock when the mutex is locked by this thread.
[SVN r84954]
2013-07-04 21:42:11 +00:00
Vicente J. Botet Escriba
9fc6fec1eb Thread: Add return type to lambda to be portable on msvc10.
[SVN r84953]
2013-07-04 21:40:15 +00:00
Vicente J. Botet Escriba
29babb974e Thread: remove warning in barrier.hpp.
[SVN r84952]
2013-07-04 21:38:33 +00:00
Vicente J. Botet Escriba
66578bf57b Thread: rollback change in #8070 as this includes a regression on windows XP.
[SVN r84946]
2013-07-03 21:16:49 +00:00
Vicente J. Botet Escriba
1da5f9563c Thread: make use of barrier on test sync_queue/multi_thread_pass.cpp and remove some warnings in sync_queue|sync_bounded_queue/single_thread_pass.cpp tests.
[SVN r84911]
2013-06-28 06:00:44 +00:00
Vicente J. Botet Escriba
52039f75a3 Thread: fix some issues with sync_bounded_queue and added tests.
[SVN r84888]
2013-06-23 20:47:03 +00:00
Vicente J. Botet Escriba
bb6fcc3b5c Thread: unused parameter warning removal.
[SVN r84887]
2013-06-23 20:45:26 +00:00
Vicente J. Botet Escriba
6225c8309a Thread: merge fix for msvc 8/9 regression.
[SVN r84870]
2013-06-21 23:10:48 +00:00
Vicente J. Botet Escriba
1fc1d8aedb Thread: Added future unwrapp constructor.
[SVN r84810]
2013-06-16 21:29:52 +00:00
Vicente J. Botet Escriba
042a86c984 Thread: added completion function on barrier class.
[SVN r84809]
2013-06-16 21:27:59 +00:00
Vicente J. Botet Escriba
364f3ea030 Thread: try to fix regression on MSVC 8/9.
[SVN r84807]
2013-06-16 19:34:25 +00:00
Vicente J. Botet Escriba
fe8991b7fa Thread: fix #8458 and update doc.
[SVN r84792]
2013-06-15 10:35:45 +00:00
Vicente J. Botet Escriba
c87d27a06d Thread: update history, compliance and fix some parts in external locking doc.
[SVN r84771]
2013-06-14 05:50:29 +00:00
Vicente J. Botet Escriba
68d7c69a4b Thread: update future ref doc.
[SVN r84770]
2013-06-14 05:46:11 +00:00
Vicente J. Botet Escriba
f4fb2c1ab0 Thread: merge fixes for #8422, #8458, #8674.
[SVN r84750]
2013-06-12 20:54:44 +00:00
Vicente J. Botet Escriba
6873d85650 Thread: Added future::unwrap()/get_or()/fallback_to().
[SVN r84719]
2013-06-09 21:41:00 +00:00
Vicente J. Botet Escriba
b59e57e4cc Thread: used cons& in deleted constructors and assignment simulation.
[SVN r84718]
2013-06-09 21:29:17 +00:00
Vicente J. Botet Escriba
582649ed44 Thread: fix #8550, #8671, #8672.
[SVN r84717]
2013-06-09 17:18:15 +00:00
Vicente J. Botet Escriba
d0f9d6216a Thread: remove const on strict locks mutex() function.
[SVN r84712]
2013-06-09 09:15:26 +00:00
Vicente J. Botet Escriba
28564064ff Thread: update history and document force use of Boost.Chrono on windows platforms.
[SVN r84711]
2013-06-09 09:07:05 +00:00
Vicente J. Botet Escriba
ff9636b8e0 Thread: take in account wait_abandoned.
[SVN r84710]
2013-06-09 08:28:28 +00:00
Vicente J. Botet Escriba
d83d23bee0 Thread: force use of chrono on windows.
[SVN r84709]
2013-06-09 08:27:00 +00:00
Vicente J. Botet Escriba
63f35e9f52 Thread: Added test_8674.cpp test.
[SVN r84691]
2013-06-08 16:04:46 +00:00
Vicente J. Botet Escriba
5ad38d52e8 Thread: update doc external_locking.qbk to remove const in mutex() function.
[SVN r84690]
2013-06-08 15:47:00 +00:00
Vicente J. Botet Escriba
9d6cd40d8d Thread: cleanup test_8596.cpp.
[SVN r84689]
2013-06-08 14:54:46 +00:00
Vicente J. Botet Escriba
4362cd655e Thread: update future doc with void set_exception_at_thread_exit(E p).
[SVN r84688]
2013-06-08 14:50:26 +00:00
Vicente J. Botet Escriba
0c44630029 Thread: fix bug on future::then when the continuation is void() ir T&().
[SVN r84685]
2013-06-08 10:53:46 +00:00
Vicente J. Botet Escriba
a01af79331 Thread: apply patch #8550.
[SVN r84684]
2013-06-08 08:21:34 +00:00
Vicente J. Botet Escriba
2df6ce78a4 Thread: fix promise set_at_..._thread_exit; Added preconditions.
[SVN r84678]
2013-06-07 19:03:49 +00:00
Vicente J. Botet Escriba
74891c9836 Thread: Merge history and fix #8645.
[SVN r84629]
2013-06-04 06:08:49 +00:00
Vicente J. Botet Escriba
3951871d70 Thread: update history and fix typo on strict_lock.
[SVN r84628]
2013-06-04 06:02:20 +00:00
Vicente J. Botet Escriba
9dd08547f7 Thread: merge 84331 to fix #8576.
[SVN r84627]
2013-06-04 06:01:54 +00:00
Vicente J. Botet Escriba
c6dbb0c9a5 Thread: merge 84540 to fiw #8626; fix show stopper in packaged_task<void()>.
[SVN r84623]
2013-06-03 16:53:59 +00:00
Vicente J. Botet Escriba
5a1a9df623 Thread: fix shared_future::get when the shared state is async; refactor the shared_state classes.
[SVN r84607]
2013-06-02 05:56:13 +00:00
Vicente J. Botet Escriba
a6f67e25e3 Thread: fix packaged_task<void()> issue and add tests.
[SVN r84597]
2013-06-01 14:27:16 +00:00
Vicente J. Botet Escriba
b69ec54695 Thread: continue the future.hpp renaming using shared_state.
[SVN r84590]
2013-06-01 07:05:35 +00:00
Vicente J. Botet Escriba
465aee1b66 Thread: Added test for #8596.
[SVN r84589]
2013-06-01 05:11:34 +00:00
Vicente J. Botet Escriba
14d3c59682 Thread added shared_future::then tests.
[SVN r84548]
2013-05-29 20:48:37 +00:00
Vicente J. Botet Escriba
3f2d8f8865 Thread: Added shared_future::then doc.
[SVN r84544]
2013-05-29 06:22:44 +00:00
Vicente J. Botet Escriba
dc8449bd0e Thread: Added shared_future::then.
[SVN r84541]
2013-05-28 20:25:34 +00:00
Vicente J. Botet Escriba
d3a6277714 Thread: Reintroduce BOOST_VERIFY on pthread_mutex_destroy return type #8626.
[SVN r84540]
2013-05-28 20:06:51 +00:00
Vicente J. Botet Escriba
81d8944b96 Thread: fix some typos on external locking.
[SVN r84539]
2013-05-28 20:01:34 +00:00
Vicente J. Botet Escriba
54faaaf087 Thread: replace asynchronous result by shared state on the future doc and add value_type on futures and promise.
[SVN r84521]
2013-05-26 21:28:17 +00:00
Vicente J. Botet Escriba
5a43d5ffe9 Thread: fix copy_exception ambiguity.
[SVN r84520]
2013-05-26 21:26:25 +00:00
Vicente J. Botet Escriba
c628e51e6c Thread: little refactoring on future.hpp; Added make_ready_future.
[SVN r84493]
2013-05-25 12:44:43 +00:00
Vicente J. Botet Escriba
0b2c57876f Thread: update history.
[SVN r84490]
2013-05-25 12:08:54 +00:00
Vicente J. Botet Escriba
a66b269198 Thread: update history.
[SVN r84489]
2013-05-25 12:01:22 +00:00
Vicente J. Botet Escriba
9e07202e21 Thread: rename internal future_object class by shared_state.
[SVN r84474]
2013-05-25 06:36:37 +00:00
Vicente J. Botet Escriba
ba03de1f06 Thread: merge 84414 to fix #8596.
[SVN r84468]
2013-05-24 21:27:53 +00:00
Vicente J. Botet Escriba
9e2a34ca9d Thread: extend duration check from 200ms to 300ms.
[SVN r84467]
2013-05-24 21:24:13 +00:00
Vicente J. Botet Escriba
4cf80c6685 Thread: update latch to use generation to prevent spurious wake-ups.
[SVN r84421]
2013-05-22 17:18:23 +00:00
Vicente J. Botet Escriba
455c31c0e9 Thread: fix inspection issues.
[SVN r84420]
2013-05-22 17:13:03 +00:00
Vicente J. Botet Escriba
a8d5fd48c1 Thread: fix warning.
[SVN r84419]
2013-05-22 17:11:31 +00:00
Vicente J. Botet Escriba
294a5404c2 Thread: fix inspection issues
[SVN r84418]
2013-05-22 17:09:49 +00:00
Vicente J. Botet Escriba
6d01267030 Thread: manage with #8596.
[SVN r84414]
2013-05-22 05:40:58 +00:00
Vicente J. Botet Escriba
1c48d237a8 Thread: fix sur parolle.
[SVN r84331]
2013-05-17 19:24:19 +00:00
Vicente J. Botet Escriba
11ae5c8c44 Thread: fix inspection report.
[SVN r84330]
2013-05-17 19:22:25 +00:00
Vicente J. Botet Escriba
9d10bd035a Thread: fix inspection report.
[SVN r84329]
2013-05-17 19:20:45 +00:00
Vicente J. Botet Escriba
100bd73f03 Thread: merge last externally°locked evolution + async_funct.
[SVN r84198]
2013-05-09 04:49:18 +00:00
Vicente J. Botet Escriba
7b48c02d2f Thread: fix warning
[SVN r84185]
2013-05-07 22:18:15 +00:00
Vicente J. Botet Escriba
d8a9331464 Thread: Rollback unwanted and unchecked change
[SVN r84138]
2013-05-04 16:03:48 +00:00
Vicente J. Botet Escriba
b60968b045 Thread: remove definition of BOOST_THREAD_NOEXCEPT_OR_THROW.
[SVN r84134]
2013-05-04 09:05:11 +00:00
Vicente J. Botet Escriba
da41bdb632 Thread: update externally_locked.
[SVN r84110]
2013-05-02 15:42:12 +00:00
Vicente J. Botet Escriba
5fcfd0e4e8 Thread: update the externally_locked_stream interface.
[SVN r84109]
2013-05-02 15:32:29 +00:00
Vicente J. Botet Escriba
4d2110f5e5 Thread: merge latch; invoke.
[SVN r84101]
2013-05-01 16:40:32 +00:00
Vicente J. Botet Escriba
2d2d1112d6 Thread: replace boost:tuple in async_func.hpp as not movable until the patch is applied.
[SVN r84098]
2013-05-01 09:19:18 +00:00
Vicente J. Botet Escriba
7cf6934515 Thread: Added #8508 test.
[SVN r84097]
2013-05-01 09:17:39 +00:00
Vicente J. Botet Escriba
757327ba10 Thread: apply patch for #8530.
[SVN r84096]
2013-05-01 08:18:03 +00:00
Vicente J. Botet Escriba
a82843d3ab Thread: update Future section.
[SVN r84084]
2013-04-29 11:45:03 +00:00
Vicente J. Botet Escriba
5779f6676d Thread: update externally_locked with assignment.
[SVN r84076]
2013-04-28 20:12:28 +00:00
Vicente J. Botet Escriba
b359424858 Thread: refactor latch by adding an internal counter that has an associated condition_variable and add doc.
[SVN r84075]
2013-04-28 20:09:50 +00:00
Vicente J. Botet Escriba
a5f7d92960 Thread: fix some typos in externally_locked doc.
[SVN r84065]
2013-04-28 12:12:38 +00:00
Vicente J. Botet Escriba
83167d8c15 Thread: make barrier not copyable.
[SVN r84064]
2013-04-28 12:10:24 +00:00
Vicente J. Botet Escriba
7d2270f8c8 Thread: try to fix time based functions.
[SVN r84056]
2013-04-27 14:39:45 +00:00
Vicente J. Botet Escriba
f87dbb83b1 Thread: Added latch and completion_latch classes.
[SVN r84055]
2013-04-27 06:51:18 +00:00
Vicente J. Botet Escriba
1a613d03a9 Thread: Added call_once test with boost::ref().
[SVN r84005]
2013-04-21 16:39:04 +00:00
Vicente J. Botet Escriba
d42f4ff169 Thread: re-apply the change to invoke as it works for gcc but not for msvc.
[SVN r84004]
2013-04-21 15:32:16 +00:00
Vicente J. Botet Escriba
ffbcf96d90 Thread: let a little bit more time.
[SVN r84003]
2013-04-21 15:04:05 +00:00
Vicente J. Botet Escriba
e294e6bcc8 Thread fix #8451.
[SVN r83995]
2013-04-21 07:34:19 +00:00
Vicente J. Botet Escriba
093a329c1a Thread: fix #8443.
[SVN r83993]
2013-04-21 07:30:55 +00:00
Vicente J. Botet Escriba
f5e246ebb0 Thread: rollback comments on invoke as there is a regression on msvc.
[SVN r83988]
2013-04-20 16:31:10 +00:00
Vicente J. Botet Escriba
467a88c4f8 Thread: make use of _POSIX_TIMEOUTS instead of _POSIX_C_SOURCE on the definition BOOST_PTHREAD_HAS_TIMEDLOCK #8443.
[SVN r83962]
2013-04-18 21:34:32 +00:00
Vicente J. Botet Escriba
f021bad1d5 Thread: update changes.
[SVN r83951]
2013-04-18 06:45:01 +00:00
Vicente J. Botet Escriba
ecd97ec4ea Thread: make invoke/async_tuple/tuple_indices more portable.
[SVN r83950]
2013-04-18 06:44:09 +00:00
Vicente J. Botet Escriba
c71882816c Thread: add missing joinable in scoped_thread #8451 + construction from F, Args.
[SVN r83949]
2013-04-18 06:43:19 +00:00
Vicente J. Botet Escriba
ef5d43fac9 Thread: make unnifor definition of BOOST_PTHREAD_HAS_TIMEDLOCK #8443.
[SVN r83948]
2013-04-18 06:41:42 +00:00
Vicente J. Botet Escriba
13141f8ada Thread: merge from trunk to fix #6843,#6966.
[SVN r83938]
2013-04-17 04:30:48 +00:00
Vicente J. Botet Escriba
fb5404947e Thread: update history.
[SVN r83910]
2013-04-14 23:07:10 +00:00
Vicente J. Botet Escriba
64c73fac46 Detail: Added undef/redef Intel atomic macros.
[SVN r83909]
2013-04-14 22:50:18 +00:00
Vicente J. Botet Escriba
f24086fe89 Thread: #6966.
[SVN r83908]
2013-04-14 22:34:10 +00:00
Vicente J. Botet Escriba
3e64214e68 Thread: Added Move traits include file.
[SVN r83906]
2013-04-14 21:34:09 +00:00
Vicente J. Botet Escriba
ed4f0f7b6d Thread: apply patch for #6843.
[SVN r83904]
2013-04-14 21:29:02 +00:00
Vicente J. Botet Escriba
50c18d6274 Detail: Added undef/redef atomic intel macros #6842/#6843.
[SVN r83903]
2013-04-14 21:23:39 +00:00
Vicente J. Botet Escriba
d5cf734a21 Thread: remove noexcept on operations that can unlock the mutex.
[SVN r83902]
2013-04-14 20:31:40 +00:00
Vicente J. Botet Escriba
43f0c059d3 Thread: Added test from [Boost-users] [boost][thread] Future returning 0xfeeefeee.
[SVN r83895]
2013-04-14 12:40:44 +00:00
Vicente J. Botet Escriba
e775ef5c27 Thread: update ref doc for future::then.
[SVN r83817]
2013-04-08 20:10:47 +00:00
Vicente J. Botet Escriba
06b7a41add Thread: update ref doc for concurrent queues.
[SVN r83815]
2013-04-08 19:14:31 +00:00
Vicente J. Botet Escriba
22369e9d8c Thread: merge from trunk 1.54: Added lambda tests, refactored future::then, added tests for future::wait...
[SVN r83811]
2013-04-08 17:23:02 +00:00
Vicente J. Botet Escriba
06d2a11127 Thread: rollback BOOST_THREAD_PROVIDES_ONCE_CXX11 define. Force minwg to use BOOST_THREAD_USE_LIB.
[SVN r83796]
2013-04-07 19:01:22 +00:00
Vicente J. Botet Escriba
6dd195bbc6 Thread: Added tennis example to regression tests.
[SVN r83795]
2013-04-07 18:43:53 +00:00
Vicente J. Botet Escriba
8a259612cd Thread: renamed all the examples as ex_; Added some lambda test.
[SVN r83762]
2013-04-04 00:04:16 +00:00
Vicente J. Botet Escriba
9fb88b8f47 Thread: don't define BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET on future::then tests.
[SVN r83678]
2013-04-01 17:47:17 +00:00
Vicente J. Botet Escriba
528fcbde56 Thread: major rewrite of future::then.
[SVN r83676]
2013-04-01 16:17:05 +00:00
Vicente J. Botet Escriba
a0397315b2 Thread: minor update in future.hpp to rework future::then.
[SVN r83672]
2013-04-01 07:41:32 +00:00
Vicente J. Botet Escriba
44ec248340 Thread: Added shared_future<>::wait... tests.
[SVN r83667]
2013-03-31 15:16:25 +00:00
Vicente J. Botet Escriba
7eba48576c Thread: added future<>::wait... tests.
[SVN r83666]
2013-03-31 14:47:11 +00:00
Vicente J. Botet Escriba
677dbe7688 Thread: merge from trunk 1.54. Fix #8027,#8323,#8337.
[SVN r83660]
2013-03-31 10:56:43 +00:00
Vicente J. Botet Escriba
451027deec Thread: doc updated with sync queues draft and sections reorganization.
[SVN r83654]
2013-03-30 18:39:35 +00:00
Vicente J. Botet Escriba
16b42b6c63 Thread: added non-interleaved externally_locked stream example to regression tests.
[SVN r83653]
2013-03-30 18:38:03 +00:00
Vicente J. Botet Escriba
a543b918f0 Thread: check for time_points in the past on try_join_until to take care of #8323.
[SVN r83652]
2013-03-30 18:28:29 +00:00
Vicente J. Botet Escriba
619ddf54b9 Thread: remove what() function from future_error to take care of #8337.
[SVN r83649]
2013-03-30 14:36:41 +00:00
Vicente J. Botet Escriba
116c947af9 Thread: replace wait_and_ope by ope in sync_queues and pop by pull.
[SVN r83648]
2013-03-30 14:33:42 +00:00
Vicente J. Botet Escriba
a0931c117d Thread: return 0.
[SVN r83645]
2013-03-30 09:37:43 +00:00
Vicente J. Botet Escriba
79e1e88f2e Thread: more refactoring on pthread/shared_mutex.hpp.
[SVN r83553]
2013-03-24 23:45:33 +00:00
Vicente J. Botet Escriba
af3b5f3227 Thread: limit dependency on boost/thread/thread.hpp.
[SVN r83552]
2013-03-24 22:05:50 +00:00
Vicente J. Botet Escriba
7bebf0a062 Thread: fix typo __Lockable.
[SVN r83551]
2013-03-24 22:02:44 +00:00
Vicente J. Botet Escriba
6dad044ab7 Thread: avoid the use of boost/thread/thread.hpp to limit dependencies.
[SVN r83548]
2013-03-24 18:30:55 +00:00
Vicente J. Botet Escriba
19bd0d5eba Thread: Added first version of sync_queue.
[SVN r83547]
2013-03-24 18:29:03 +00:00
Vicente J. Botet Escriba
f922fa56e4 Thread: Added assertions on pthread/shared_mutex.hpp; fixed two shared_mutex tests that were wrong.
[SVN r83546]
2013-03-24 17:18:21 +00:00
Vicente J. Botet Escriba
290faf192d Thread: Added first version of sync_bounded_queue.
[SVN r83538]
2013-03-24 12:24:22 +00:00
Vicente J. Botet Escriba
054bbad65a Thread: update doc addin the missing traits is_recursive_lockable and is_recursive_basic_lockable; Added lock/try_lock requires clause; Added call_once restrictions.
[SVN r83534]
2013-03-23 18:05:10 +00:00
Vicente J. Botet Escriba
b1a674869d Thread: merge from trunk. 1.54
[SVN r83525]
2013-03-23 01:48:21 +00:00
Vicente J. Botet Escriba
df7fbe085a Thread: Added constexpr to future default constructor; protect code incompatible with MSVC8.
[SVN r83521]
2013-03-22 21:50:20 +00:00
Vicente J. Botet Escriba
b03cebff7b Thread: protect some tests with BOOST_THREAD_PROVIDES_VARIADIC_THREAD.
[SVN r83503]
2013-03-19 22:35:50 +00:00
Vicente J. Botet Escriba
c9c46e87b5 Thread: Adapt win32/once.hpp to last changes to invoke..
[SVN r83471]
2013-03-17 08:07:40 +00:00
Vicente J. Botet Escriba
d4e6332eca Thread: add invoke when no variadic templates are available; adapt call_once.
[SVN r83466]
2013-03-16 15:36:21 +00:00
Vicente J. Botet Escriba
80594adcbb Thread: fixed some typos on win32/once.hpp and made use bind when there are some arguments and specialize the algorithm when there are no parameters to avoid errors with bind.
[SVN r83465]
2013-03-16 15:35:10 +00:00
Vicente J. Botet Escriba
4ea14fb9da Thread: rollback one of the changes in [83425].
[SVN r83456]
2013-03-16 08:32:22 +00:00
Vicente J. Botet Escriba
5a22af7639 Thread: force BOOST_THREAD_USES_DATETIME on windows #8198.
[SVN r83426]
2013-03-14 17:23:05 +00:00
Vicente J. Botet Escriba
7b157ab5f4 Thread: Apply patch for #8212.
[SVN r83425]
2013-03-14 17:19:59 +00:00
Vicente J. Botet Escriba
a73425eb00 Thread: use invoke/bind whenever there is atleast one parameter on call_once.
[SVN r83422]
2013-03-13 23:01:49 +00:00
Vicente J. Botet Escriba
b254afc229 Thread: use Boost/Move in invoke.
[SVN r83421]
2013-03-13 22:58:12 +00:00
Vicente J. Botet Escriba
a1edda3437 Thread: Added changes for 1.54.
[SVN r83420]
2013-03-13 22:49:22 +00:00
Vicente J. Botet Escriba
c784369f76 Thread: try to fix call_once for MSVC 8.0,9.0
[SVN r83400]
2013-03-10 17:36:40 +00:00
Vicente J. Botet Escriba
0b7462c4f2 Thread: notify win32/shared_mutex when setting new_state.exclusive_waiting_blocked=false;
[SVN r83397]
2013-03-10 15:17:50 +00:00
Vicente J. Botet Escriba
23ff6e0120 Thread: Added noexcep to some synchronized_value constructors + doc.
[SVN r83396]
2013-03-10 14:54:59 +00:00
Vicente J. Botet Escriba
06491889ea Thread: Try workaround for #8212.
[SVN r83370]
2013-03-09 16:00:22 +00:00
Vicente J. Botet Escriba
abf441ee63 Thread: try to fix double definition of GetTickCount64.
[SVN r83318]
2013-03-05 18:57:34 +00:00
Vicente J. Botet Escriba
9615a51123 Thread: #8237, 8239
[SVN r83312]
2013-03-05 18:05:48 +00:00
Vicente J. Botet Escriba
a0bfa7faeb Thread: activate synchronized_value tests
[SVN r83295]
2013-03-04 18:15:27 +00:00
Vicente J. Botet Escriba
44b741e445 Thread: make use of _WIN32_WINNT instead of WINNT.
[SVN r83294]
2013-03-04 17:52:49 +00:00
Vicente J. Botet Escriba
41d336e7fb Thread: added test for #7755.
[SVN r83286]
2013-03-03 19:13:58 +00:00
Vicente J. Botet Escriba
fc177914e1 Thread: take care of #8136
[SVN r83282]
2013-03-03 14:07:28 +00:00
Vicente J. Botet Escriba
d0056e0cc8 Thread: fix typo on synchronized_value.hp and initialize id_ on testable_mutex.
[SVN r83281]
2013-03-03 13:56:40 +00:00
Vicente J. Botet Escriba
6075cf2df6 Thread: Added test for synchronized_value + synchronize free function
[SVN r83266]
2013-03-03 11:02:31 +00:00
Vicente J. Botet Escriba
1eacb8c71d Thread: Added comments to synchronized_value + synchronize free function
[SVN r83265]
2013-03-03 11:01:07 +00:00
Vicente J. Botet Escriba
7476f71af6 Thread: go towards testable_mutex
[SVN r83264]
2013-03-03 10:55:13 +00:00
Vicente J. Botet Escriba
d86b5d2c0d Thread: Added some synchronized_value tests
[SVN r83262]
2013-03-03 10:22:35 +00:00
Vicente J. Botet Escriba
09f86d603e Thread: fix typo on return value
[SVN r83261]
2013-03-03 10:14:16 +00:00
Vicente J. Botet Escriba
ca3d7dab0b Thread: remove warning
[SVN r83260]
2013-03-03 09:53:25 +00:00
Vicente J. Botet Escriba
7e35a60650 Thread: remove warning
[SVN r83259]
2013-03-03 09:50:26 +00:00
Vicente J. Botet Escriba
2b5bd7275e Thread: Make use of GetTickCount64 when available
[SVN r83258]
2013-03-03 09:45:48 +00:00
Vicente J. Botet Escriba
ca37d07184 Thread: Added value semantics to synchronized value
[SVN r83086]
2013-02-22 17:42:44 +00:00
Vicente J. Botet Escriba
6f2efbcb32 Thread: Added doc on call_once + synchronized_value + lockable_adapter.
[SVN r83085]
2013-02-22 17:25:20 +00:00
Vicente J. Botet Escriba
1ce6a90f95 Thread: see if the use of lightweight_test removes the error: double free or corruption.
[SVN r83040]
2013-02-19 22:45:10 +00:00
Vicente J. Botet Escriba
0a101e15d1 Thread: commit proposed patch for #7720.
[SVN r82973]
2013-02-18 12:11:09 +00:00
Vicente J. Botet Escriba
d2f7766f8a Thread: inhibit msvc warning
[SVN r82955]
2013-02-17 16:16:24 +00:00
Vicente J. Botet Escriba
ba7a0935f2 Thread: added missing include for #7720.
[SVN r82954]
2013-02-17 16:13:54 +00:00
Vicente J. Botet Escriba
7277a94411 Thread: refactor may_alias on once_atomic.hpp.
[SVN r82951]
2013-02-17 15:04:06 +00:00
Vicente J. Botet Escriba
197bbc1fd3 Thread: remove warnings.
[SVN r82950]
2013-02-17 14:59:57 +00:00
Vicente J. Botet Escriba
b9e2d7b13d Thread: prepare for HH shared_mutex.
[SVN r82946]
2013-02-17 10:11:46 +00:00
Hartmut Kaiser
579501d98e Thread: Fixing annoying Windows compilation warning
[SVN r82943]
2013-02-17 04:44:05 +00:00
Vicente J. Botet Escriba
dc352450ca Thread: added load test for shared_mutex.
[SVN r82925]
2013-02-16 15:11:19 +00:00
Vicente J. Botet Escriba
21b2bbc8ca Thread: make use of atomic on the header of once_atomic to avoid not needed cast that report some warnings.
[SVN r82905]
2013-02-15 17:05:49 +00:00
Vicente J. Botet Escriba
bd9105a104 Thread: try to fix some vacpp errors on regression tests.
[SVN r82861]
2013-02-13 22:01:33 +00:00
Vicente J. Botet Escriba
935d851cdf Thread: move local static variable to file scope in future_category.
[SVN r82843]
2013-02-12 20:14:11 +00:00
Vicente J. Botet Escriba
68142e8ff8 Thread: cleanup perf_shared_mutex.cpp.
[SVN r82842]
2013-02-12 20:12:20 +00:00
Vicente J. Botet Escriba
f9b257e368 Thread: merge from trunk 1.54 - once_atomic; null_mutex
[SVN r82838]
2013-02-12 18:32:00 +00:00
Anthony Williams
1dad495280 Modify mark_waiting_and_try_lock to return modified count if mutex already locked
[SVN r82828]
2013-02-12 08:21:40 +00:00
Vicente J. Botet Escriba
fb2310b48a Thread: Add vacpp-12.1 to the compilers using chrono.
[SVN r82826]
2013-02-11 22:52:52 +00:00
Vicente J. Botet Escriba
247e9a4f09 Thread: Fixed null_mutex initialization + added tests some tests.
[SVN r82823]
2013-02-11 18:43:33 +00:00
Vicente J. Botet Escriba
c1ec1ada0e Thread: remove no more needed and failing function remove_unused_warning.
[SVN r82809]
2013-02-10 21:37:50 +00:00
Vicente J. Botet Escriba
d030dbd61c Thread: fix some issues with futures of MoveOnly types + complete the variadic async function.
[SVN r82808]
2013-02-10 18:14:49 +00:00
Vicente J. Botet Escriba
bebd56ee21 Thread: fix synchronized_value move constructor.
[SVN r82795]
2013-02-09 14:05:55 +00:00
Vicente J. Botet Escriba
75586eec0e Thread: manage #7980
[SVN r82777]
2013-02-07 18:43:50 +00:00
Vicente J. Botet Escriba
659343d287 Thread: link with Boost.Atomic when compiling for vacpp
[SVN r82776]
2013-02-07 17:06:10 +00:00
Vicente J. Botet Escriba
8e63c72867 Thread: Added timed_lock functions to HH shared_mutex implementation so that we can replace the current shared_mutex by the HH one.
[SVN r82762]
2013-02-06 17:57:16 +00:00
Vicente J. Botet Escriba
65416bb8b6 Thread: make the pthread binary to don't depend on shared_mutex.hpp + #7982
[SVN r82757]
2013-02-06 06:40:30 +00:00
Vicente J. Botet Escriba
71a647b66b Thread: make shared_mutext HH implementation header-only.
[SVN r82746]
2013-02-04 20:22:13 +00:00
Vicente J. Botet Escriba
8416d3e8bb Thread: merge [82645].
[SVN r82650]
2013-01-27 21:50:23 +00:00
Vicente J. Botet Escriba
fc57e9dde0 Thread: Update win32/once.hpp to take care of variadin rvalu call_once parameters.
[SVN r82649]
2013-01-27 21:30:51 +00:00
Vicente J. Botet Escriba
4acfe0975c Thread: Update win32/once.hpp to take care of variadin rvalu call_once parameters.
[SVN r82648]
2013-01-27 21:28:59 +00:00
Vicente J. Botet Escriba
158e8ead50 Thread: update perf shared_mutex file
[SVN r82647]
2013-01-27 21:24:38 +00:00
Vicente J. Botet Escriba
0fc69c4d9e Thread: update H.Hinnant implementation to make it work on Windows.
[SVN r82646]
2013-01-27 21:22:58 +00:00
Vicente J. Botet Escriba
e314bf03ce Thread: fix issue when BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS is defined on win32/pthread.cpp
[SVN r82645]
2013-01-27 20:16:54 +00:00
Vicente J. Botet Escriba
6f2decdacf Thread: added shred mutex impl based on H. Hinnant one
[SVN r82638]
2013-01-27 17:55:00 +00:00
Vicente J. Botet Escriba
4bd3e09a0d Thread: Added performance test for shared_mutex.
[SVN r82637]
2013-01-27 17:29:24 +00:00
Vicente J. Botet Escriba
8b89d21814 Thread: Fix #7918
[SVN r82635]
2013-01-27 13:33:42 +00:00
Vicente J. Botet Escriba
a16f508b8a Thread: Added two more test cases for call_once for thread I/F.
[SVN r82624]
2013-01-26 16:20:05 +00:00
Vicente J. Botet Escriba
1642db3441 Thread: enable BOOST_THREAD_PROVIDES_ONCE_CXX11 on cal_once_pass test
[SVN r82613]
2013-01-25 20:53:49 +00:00
Vicente J. Botet Escriba
8804ab8e73 Thread: merge async_pass timeout extension: [82542].
[SVN r82568]
2013-01-20 17:14:51 +00:00
Vicente J. Botet Escriba
b389079417 Thread: improve call_once using invoke/bind and rvalue references
[SVN r82566]
2013-01-20 17:06:33 +00:00
Vicente J. Botet Escriba
8f7be637b2 Thread: comment BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN define to make evident the bug.
[SVN r82551]
2013-01-19 18:08:20 +00:00
Vicente J. Botet Escriba
94c15aa0cc Thread: changes to fix PGI compiler adding lib atomic.
[SVN r82548]
2013-01-19 08:33:06 +00:00
Vicente J. Botet Escriba
951c8952ff Thread: Added variadic call_once for windows
[SVN r82543]
2013-01-18 22:36:28 +00:00
Vicente J. Botet Escriba
59f91a2405 Thread: extend the timeout in test async_pass.
[SVN r82542]
2013-01-18 22:04:27 +00:00
Vicente J. Botet Escriba
f4a3d52654 Thread: fix call_once when atomic is not used.
[SVN r82530]
2013-01-18 07:18:55 +00:00
Vicente J. Botet Escriba
517e177d7a Thread: minor changes to fix PGI compiler adding lib atomic
[SVN r82529]
2013-01-17 21:09:55 +00:00
Vicente J. Botet Escriba
e72184e9ee Thread: Added atomic once implementation + variadi call_once for pthread
[SVN r82513]
2013-01-16 21:49:59 +00:00
Vicente J. Botet Escriba
0ba92626f0 Thread; merge 82471
[SVN r82502]
2013-01-15 20:19:33 +00:00
Vicente J. Botet Escriba
ce46c31555 Thread: merge 82459,82457,82456,82455
[SVN r82491]
2013-01-14 17:17:50 +00:00
Vicente J. Botet Escriba
73348d69d2 Thread: added specific macros to state if some lock factories are not provided
[SVN r82471]
2013-01-12 22:21:58 +00:00
Vicente J. Botet Escriba
15eff9e412 Thread: adjust some durations on tests
[SVN r82459]
2013-01-12 09:48:54 +00:00
Vicente J. Botet Escriba
dd70cd5b40 Thread: change text associated to exceptions #7882.
[SVN r82457]
2013-01-12 09:05:55 +00:00
Vicente J. Botet Escriba
b290f995d0 Thread: try to remove warning for #7874
[SVN r82456]
2013-01-12 09:03:19 +00:00
Vicente J. Botet Escriba
c1dd0e1e43 Thread: comment not thread-safe check for the time been. atomic<> should be used insted.
[SVN r82455]
2013-01-12 08:52:26 +00:00
Vicente J. Botet Escriba
e160cf0254 Thread: merge from trun 1.53: some minor fixes on the regression tests.
[SVN r82437]
2013-01-10 21:38:43 +00:00
Vicente J. Botet Escriba
44a02c1f5f Thread: don't set BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED by default.
[SVN r82436]
2013-01-10 21:35:13 +00:00
Vicente J. Botet Escriba
a0071b301b Thread: Added BOOST_THREAD_NO_CXX11_HDR_TUPLE to wrokarround msvc 10.0 behavior providing <tuple> without move semantics
[SVN r82410]
2013-01-08 22:00:02 +00:00
Vicente J. Botet Escriba
c77281f724 Thread: make the mutex type of externally_locked_stream a template parameter. Polymorfic recursive mutex will be needed if the stream mutex map needs to be external.
[SVN r82397]
2013-01-08 01:28:28 +00:00
Vicente J. Botet Escriba
8a0578c93c Thread: improve external lock for externally_locked_stream.
[SVN r82392]
2013-01-07 23:13:43 +00:00
Vicente J. Botet Escriba
c7dcb1daae Thread: fix typo
[SVN r82375]
2013-01-06 10:06:40 +00:00
Vicente J. Botet Escriba
af330fb61b Thread: try to not run some tests when threadapi is win32.
[SVN r82370]
2013-01-05 22:59:07 +00:00
Vicente J. Botet Escriba
ab64afa2a7 Thread: extend the vacpp versions where boost-cheono is accepted
[SVN r82369]
2013-01-05 22:57:03 +00:00
Vicente J. Botet Escriba
85792f9946 Thread: try to see if this solves some vacpp issues
[SVN r82368]
2013-01-05 22:55:50 +00:00
Vicente J. Botet Escriba
e0d4e63e48 Thread: constraint make_unique_locks when BOOST_NO_CXX11_RVALUE_REFERENCES is not defined
[SVN r82367]
2013-01-05 22:54:55 +00:00
Vicente J. Botet Escriba
67da33a182 Thread: merge from trunk latest changes.
[SVN r82356]
2013-01-04 18:40:49 +00:00
Vicente J. Botet Escriba
b2bd9f4ca9 Thread: fix typo in make_unique_locks without ariadic templates
[SVN r82342]
2013-01-03 22:10:34 +00:00
Vicente J. Botet Escriba
189356680b Thread: make use of BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX.
[SVN r82329]
2013-01-03 11:19:14 +00:00
Vicente J. Botet Escriba
d07835908f Thread: merge from trunk rollback to version 2
[SVN r82320]
2013-01-02 17:09:46 +00:00
Vicente J. Botet Escriba
0e0cd2c950 Thread: complete externally_locked_stream.
[SVN r82318]
2013-01-02 14:14:03 +00:00
Vicente J. Botet Escriba
a849a41367 Thread: fix typo on condition BOOST_NO_CXX11_HDR_TUPLE.
[SVN r82317]
2013-01-02 11:17:13 +00:00
Vicente J. Botet Escriba
4b1c13e5cb Thread: replace BOOST_NO_CXX11_HDR_INITIALIZER_LIST by specific BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST that takes in account that gcc up to 4.6 doens't supports it as expected
[SVN r82311]
2013-01-02 00:04:33 +00:00
Vicente J. Botet Escriba
f3777b9306 Thread: extend the workaround on intel compilers up to version 13.0
[SVN r82308]
2013-01-01 10:01:56 +00:00
Vicente J. Botet Escriba
3e5e12e1ac Thread: update configuration variables taking in accont the version rollback
[SVN r82307]
2013-01-01 09:45:38 +00:00
Vicente J. Botet Escriba
e618900149 Thread: merge from trunk 1.53
[SVN r82306]
2013-01-01 09:41:02 +00:00
Vicente J. Botet Escriba
a50176c259 Thread: rollback default version 3 change.
[SVN r82302]
2012-12-31 15:10:17 +00:00
Vicente J. Botet Escriba
94e524a1e6 Thread: Fix condition_variable/any::wait_for pred with boost::move
[SVN r82301]
2012-12-31 14:49:41 +00:00
Vicente J. Botet Escriba
cb3259b23f Thread: fix issue with wait_for predicate
[SVN r82299]
2012-12-31 12:42:32 +00:00
Vicente J. Botet Escriba
ec811d3c4a Thread: change resource_deadlock_would_occur from precondition to exception.
[SVN r82298]
2012-12-31 10:03:55 +00:00
Vicente J. Botet Escriba
bf67321336 Thread: wait_for description
[SVN r82297]
2012-12-31 10:02:13 +00:00
Vicente J. Botet Escriba
4b71ef9354 Thread: Added noexcept to scoped_thread
[SVN r82296]
2012-12-31 09:57:10 +00:00
Vicente J. Botet Escriba
23bf16a638 Thread: update doc
[SVN r82283]
2012-12-30 18:24:01 +00:00
Vicente J. Botet Escriba
c3ada352f4 Thread: updated history
[SVN r82162]
2012-12-21 22:52:11 +00:00
Vicente J. Botet Escriba
e012b8abb2 Thread: merge from trunk condition_variables no-it + doc
[SVN r82159]
2012-12-21 22:15:14 +00:00
Vicente J. Botet Escriba
610bdc4aca Thread: update doc ref #7812
[SVN r82107]
2012-12-19 22:58:36 +00:00
Vicente J. Botet Escriba
6675f4645f Thread: #7422: don't use internal_mutex when interruptions not enabled
[SVN r82094]
2012-12-19 10:50:23 +00:00
Vicente J. Botet Escriba
2895bfe269 Thread: #7808
[SVN r82093]
2012-12-19 06:38:56 +00:00
Vicente J. Botet Escriba
27e2d632cd Thread: #7808
[SVN r82082]
2012-12-18 17:18:17 +00:00
Vicente J. Botet Escriba
8ee9ed1904 Thread: merge doc
[SVN r82037]
2012-12-16 22:45:22 +00:00
Vicente J. Botet Escriba
abdaa7b5b3 Thread: update doc with internal and external locking
[SVN r82036]
2012-12-16 22:40:10 +00:00
Vicente J. Botet Escriba
565a022a5a Merge from trunk 1.53
[SVN r82029]
2012-12-16 19:01:45 +00:00
Vicente J. Botet Escriba
e0ed1d6d61 Thread: make set_wait_callback thread-safe.
[SVN r81975]
2012-12-15 17:44:38 +00:00
Vicente J. Botet Escriba
f8b1287153 Thread: workaroun for clang-2.8
[SVN r81968]
2012-12-15 13:13:37 +00:00
Vicente J. Botet Escriba
5ed50d68f2 Thread: replace BOOST_SYSTEM_NOEXCEPT by BOOST_NOEXCEPT
[SVN r81963]
2012-12-14 23:58:46 +00:00
Vicente J. Botet Escriba
0f7d406b9f Thread: merge [81788]-tools dir missing
[SVN r81914]
2012-12-13 21:33:57 +00:00
Vicente J. Botet Escriba
2f0a6c01c2 Thread: comment missing file
[SVN r81864]
2012-12-11 18:58:43 +00:00
Vicente J. Botet Escriba
c8edd6c795 Thread: minor refactorings
[SVN r81842]
2012-12-10 22:02:16 +00:00
Vicente J. Botet Escriba
4d5474d600 Thread: merge from trunk 1.53 strict lock tests
[SVN r81814]
2012-12-10 07:37:23 +00:00
Vicente J. Botet Escriba
2b8930a5bf System/FileSystem/Asio/Thread: ref #7278 Added noexcept to Boost.System to conform with C++11
[SVN r81808]
2012-12-09 14:47:39 +00:00
Vicente J. Botet Escriba
7c89563108 Thread: Fix comments -use instead BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
[SVN r81804]
2012-12-09 10:52:34 +00:00
Vicente J. Botet Escriba
fcb94bcecf Thread: Add more tests for _at_thread_exit functions when the source is moved.
[SVN r81792]
2012-12-08 14:05:52 +00:00
Vicente J. Botet Escriba
593e9e0f2f Thread: fix shared_ptr implicit conversion to bool introduced in [81780]
[SVN r81788]
2012-12-08 11:01:15 +00:00
Vicente J. Botet Escriba
4209dfaa7f Thread: Added make_strict_lock.
[SVN r81784]
2012-12-08 08:15:49 +00:00
Vicente J. Botet Escriba
0fac7be5b9 Thread: rename _synchronizer as _lock_ptr, and move them outside of synchronized_value so that they can be used in other contexts + update and show usage of unique_lock_ptr.
[SVN r81779]
2012-12-07 23:45:09 +00:00
Vicente J. Botet Escriba
233484f254 Thread: merge from trunk noit, default to version 3, synchronized_value move semantics
[SVN r81763]
2012-12-07 17:10:06 +00:00
Vicente J. Botet Escriba
0936913bf6 Thread: Added tests for strict_lock, nested_strict_lock
[SVN r81753]
2012-12-07 07:48:36 +00:00
Vicente J. Botet Escriba
03ebc320f1 Thread: set default version to 3
[SVN r81704]
2012-12-04 16:32:33 +00:00
Vicente J. Botet Escriba
ea11670593 Thread: fix strinct_synchronizer move error and update the example to be run on all compilers.
[SVN r81680]
2012-12-02 21:30:39 +00:00
Vicente J. Botet Escriba
607080857b Thread: uncomment unwanted comments:(.
[SVN r81674]
2012-12-02 20:17:08 +00:00
Vicente J. Botet Escriba
6728fdb3b1 Thread: make synchronized_value use Boost.Move and add some value based operations
[SVN r81673]
2012-12-02 18:30:00 +00:00
Vicente J. Botet Escriba
580c1b7be4 Thread: fix some issues when BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS is defined and add tests
[SVN r81672]
2012-12-02 14:14:09 +00:00
Vicente J. Botet Escriba
ad3247dd29 Thread: merge from trunk 1.53
[SVN r81667]
2012-12-02 09:22:33 +00:00
Vicente J. Botet Escriba
03a43d09a4 Thread: update unique_synchronizer
[SVN r81659]
2012-12-01 22:47:10 +00:00
Vicente J. Botet Escriba
7f043d7b07 Thread: uncomment failing indirection in synchronized_value
[SVN r81650]
2012-12-01 12:28:55 +00:00
Vicente J. Botet Escriba
77a8c6667f Thread: update sleep_for algo depending on whether BOOST_THREAD_SLEEP_FOR_IS_STEADY is defined or not
[SVN r81649]
2012-12-01 11:12:01 +00:00
Vicente J. Botet Escriba
418a3f6978 Thread: Added no interruption header-only tests for shared_mutex/shared_lock
[SVN r81648]
2012-12-01 11:10:43 +00:00
Vicente J. Botet Escriba
6b300d2e4c Thread: force BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
[SVN r81647]
2012-12-01 11:08:03 +00:00
Vicente J. Botet Escriba
50ae9d93a6 Thread: Use BOOST_THREAD_LOG
[SVN r81646]
2012-12-01 11:07:10 +00:00
Vicente J. Botet Escriba
168ee37d30 Thread: remove warnings
[SVN r81645]
2012-12-01 11:04:25 +00:00
Vicente J. Botet Escriba
81528d64d5 Thread: Added const_strict_synchronizer.
[SVN r81644]
2012-12-01 11:02:16 +00:00
Marshall Clow
e6b8a133a8 Removed missed usage of deprecated macros in Boost.Thread
[SVN r81593]
2012-11-27 17:26:10 +00:00
Vicente J. Botet Escriba
047ca43b72 Thread: don't use thread_data if no interruptions
[SVN r81583]
2012-11-26 22:58:00 +00:00
Vicente J. Botet Escriba
3c6509184a Thread: improve is_convertible workaround to take care bug for of gcc-4.4 and intel 10.1
[SVN r81534]
2012-11-25 18:38:42 +00:00
Vicente J. Botet Escriba
ec1ce4cf98 Thread: improve is_convertible workaround to take care bug for of gcc-4.4 and intel 10.1
[SVN r81533]
2012-11-25 18:30:19 +00:00
Vicente J. Botet Escriba
526478338d Thread: update log so that we can choose to don't use the this_thread::get_id.
[SVN r81532]
2012-11-25 18:27:06 +00:00
Vicente J. Botet Escriba
f49e6e8dc3 Thread: fix conversion when sizeof(intmax_t)>sizeof(ts.tv_sec).
[SVN r81531]
2012-11-25 18:25:35 +00:00
Vicente J. Botet Escriba
186d58eef7 Thread: update docs and some licenses
[SVN r81525]
2012-11-25 08:19:40 +00:00
Vicente J. Botet Escriba
d2bbc1b7c1 Thread: fix error introduced by 81514
[SVN r81522]
2012-11-24 21:33:11 +00:00
Ion Gaztañaga
2a503b5c81 Replace undocumented Boost.Move usage with new official Boost.Move utilities.
[SVN r81514]
2012-11-24 20:51:32 +00:00
Vicente J. Botet Escriba
a25b918a67 Thread: Added unique lock factories
[SVN r81508]
2012-11-24 16:24:27 +00:00
Vicente J. Botet Escriba
821376f552 Thread: Added make_lock_guard
[SVN r81506]
2012-11-24 12:36:46 +00:00
Vicente J. Botet Escriba
4387de4be8 Thread: add traces to future_then
[SVN r81505]
2012-11-24 08:08:10 +00:00
Vicente J. Botet Escriba
0663b30528 Thread: added internal thread-safe log utility
[SVN r81504]
2012-11-24 07:20:21 +00:00
Vicente J. Botet Escriba
37b0eb2c48 Thread: update is_convertible workaround to try to avoid a regression on intel.12.0
[SVN r81503]
2012-11-24 07:07:48 +00:00
Vicente J. Botet Escriba
de0272abcf Thread: patch #7716
[SVN r81490]
2012-11-23 06:29:30 +00:00
Vicente J. Botet Escriba
cfc3634108 Thread: format text
[SVN r81489]
2012-11-23 06:26:30 +00:00
Vicente J. Botet Escriba
1c62b1599d Thread: manage with #7575 for c++11 compliant compilers + try to fix issue with is_convertible on gcc-4.4.
[SVN r81410]
2012-11-18 10:09:12 +00:00
Vicente J. Botet Escriba
1d2ec17d52 Thread: Towards removing DateTime dependency on the library binary file.
[SVN r81398]
2012-11-17 13:46:49 +00:00
Vicente J. Botet Escriba
0d9e8a0c3c Thread: Towards removing DateTime dependency on the library binary file.
[SVN r81383]
2012-11-17 09:00:16 +00:00
Vicente J. Botet Escriba
9b28bb59c9 Thread: refactor time related conversions + move datetime deprecation to version 4
[SVN r81381]
2012-11-17 07:50:56 +00:00
Vicente J. Botet Escriba
0fce559711 Thread: towards future<>::then(launch, ...
[SVN r81291]
2012-11-11 01:05:55 +00:00
Vicente J. Botet Escriba
de191d213e Thread: deprecate BOOST_THREAD_USES_DATETIME only since version 4.
[SVN r81290]
2012-11-11 01:04:47 +00:00
Vicente J. Botet Escriba
ae89c307bf Thread: ref #7669
[SVN r81289]
2012-11-11 00:57:07 +00:00
Vicente J. Botet Escriba
0dba7ba99b Thread: update doc with history, configuration table
[SVN r81288]
2012-11-10 20:35:07 +00:00
Vicente J. Botet Escriba
1b67c83359 Thread: set default version to 2
[SVN r81283]
2012-11-10 10:34:42 +00:00
Vicente J. Botet Escriba
d28465b656 Thread: update doc with lockable traits, yuturial, compliance.
[SVN r81282]
2012-11-10 10:32:06 +00:00
Vicente J. Botet Escriba
bb3493bdf0 Thread: Added test for #7666
[SVN r81281]
2012-11-10 10:30:05 +00:00
Vicente J. Botet Escriba
0cd8326f21 Thread: deprecate nested scoped locks and DateTime based timed fuctions
[SVN r81279]
2012-11-10 10:25:33 +00:00
Vicente J. Botet Escriba
5c5c818bc5 Thread: manage with ref #7668
[SVN r81270]
2012-11-09 20:26:42 +00:00
Vicente J. Botet Escriba
124b99b2a4 Thread: Added missing include
[SVN r81264]
2012-11-09 16:56:36 +00:00
Vicente J. Botet Escriba
1cabac151a Thread: fix typo.
[SVN r81263]
2012-11-09 16:46:47 +00:00
Vicente J. Botet Escriba
df48b734a2 Thread: rollback to manage with #7657
[SVN r81254]
2012-11-08 20:26:32 +00:00
Vicente J. Botet Escriba
039d744960 Thread added packaged_task__make_ready_at_thread_exit_pass test
[SVN r81225]
2012-11-06 17:20:17 +00:00
Vicente J. Botet Escriba
004e8a4fcf Thread: Added packaged_task::make_ready_at_thread_exit
[SVN r81205]
2012-11-05 17:41:09 +00:00
Vicente J. Botet Escriba
d8f8acbe38 Thread: cleanup + moving lockable traits specializations to the specific files.
[SVN r81175]
2012-11-04 20:37:25 +00:00
Vicente J. Botet Escriba
8a01f9ee09 Thread: cleanup+uncomment catch all
[SVN r81173]
2012-11-04 17:38:09 +00:00
Vicente J. Botet Escriba
315af061cd Thread: Added promise::set_..._at_thread_exit
[SVN r81172]
2012-11-04 16:47:02 +00:00
Vicente J. Botet Escriba
18491c933d Thread added missing file
[SVN r81155]
2012-11-03 00:58:25 +00:00
Vicente J. Botet Escriba
d01c0232da Thread: Added asynch deferred on a specifc configuration+ prepare the work for async futures joining the producer thread
[SVN r81152]
2012-11-02 21:30:36 +00:00
Vicente J. Botet Escriba
91e32e3f02 Thread: extract invoke and make_tuple_indeces on specific files+change the condition to BOOST_NO_CXX11_DECLTYPE_N3276+ fix a warning when BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined
[SVN r81145]
2012-11-02 07:31:19 +00:00
Vicente J. Botet Escriba
88294f4161 Thread: Add the function pointer overloads with MSVC even if it supports rvalue references.
[SVN r81136]
2012-11-01 21:49:20 +00:00
Vicente J. Botet Escriba
9cdc23159a Thread: rollaback unintended default version change
[SVN r81132]
2012-11-01 09:52:13 +00:00
Vicente J. Botet Escriba
c95f1d95af Thread: update doc with warnigs for deprecated features + history
[SVN r81130]
2012-10-31 21:17:49 +00:00
Vicente J. Botet Escriba
45c87d392f Thread: Refactor futures by adding a basic_future common class + added some tests for shared_future
[SVN r81129]
2012-10-31 21:16:00 +00:00
Vicente J. Botet Escriba
1c0a4999b8 Thread: rework async and packaged task.
[SVN r81117]
2012-10-31 01:37:57 +00:00
Vicente J. Botet Escriba
30bfc7bcea Thread: remove some rvalue-references limitations for future::then and make_shared.
[SVN r81111]
2012-10-30 09:36:22 +00:00
Vicente J. Botet Escriba
48f8c1c1c8 Thread Split lock.hpp + towards allowing to disable interruptions
[SVN r81106]
2012-10-29 19:57:01 +00:00
Vicente J. Botet Escriba
c47ea136b6 Thread Split lock.hpp + towards allowing to disable interruptions
[SVN r81105]
2012-10-29 19:19:40 +00:00
Vicente J. Botet Escriba
a3d30b2a89 Thread: Added polymorphic lockables
[SVN r81104]
2012-10-29 19:13:32 +00:00
Vicente J. Botet Escriba
11e15ff0f2 Thread: Added an example using externally_locked_stream
[SVN r81103]
2012-10-29 19:09:47 +00:00
Vicente J. Botet Escriba
fb4b4fb14a Thread: Added externally_locked_stream
[SVN r81102]
2012-10-29 19:09:28 +00:00
Vicente J. Botet Escriba
0ede82e059 Thread: change strict_lock is_locking by own_lock and update lockable concepts
[SVN r81101]
2012-10-29 19:05:51 +00:00
Vicente J. Botet Escriba
708b660c0b Thread: change strict_lock is_locking by own_lock and update lockable concepts
[SVN r81100]
2012-10-29 19:05:35 +00:00
Vicente J. Botet Escriba
9f27bba490 Thread: Added test for #7571
[SVN r81097]
2012-10-29 12:37:53 +00:00
Vicente J. Botet Escriba
095da2890e Thread: deprecate boost::condition
[SVN r81090]
2012-10-29 01:27:53 +00:00
Vicente J. Botet Escriba
389d76cbc1 Thread: document the split of locks.hpp, StrictLock, strict_lock, null_mutex, configuration
[SVN r81089]
2012-10-29 01:25:12 +00:00
Vicente J. Botet Escriba
493cbc030c Thread: Added testable_mutex
[SVN r81088]
2012-10-29 01:12:57 +00:00
Vicente J. Botet Escriba
2f7b936cd6 Thread: Added externally_locked
[SVN r81087]
2012-10-29 01:09:58 +00:00
Vicente J. Botet Escriba
6f3ee1eebf Thread: Added scoped_thread doc
[SVN r81086]
2012-10-29 01:07:36 +00:00
Vicente J. Botet Escriba
32f7b212bd Thread: Added strict locks
[SVN r81084]
2012-10-29 01:03:31 +00:00
Vicente J. Botet Escriba
4fcdabca90 Thread: Added lockable concept checkers
[SVN r81083]
2012-10-29 00:59:57 +00:00
Vicente J. Botet Escriba
b03de37155 Thread: Added files needed to split locks.hpp in several files to limit depedencies
[SVN r81082]
2012-10-29 00:55:31 +00:00
Vicente J. Botet Escriba
73af713503 Thread: Added null_mutex
[SVN r81081]
2012-10-29 00:50:53 +00:00
Vicente J. Botet Escriba
a903532cef Thread: make use of the extracted thread functiors and added default constructor
[SVN r81080]
2012-10-29 00:39:59 +00:00
Vicente J. Botet Escriba
d6178b3139 Thread: update thread_guard to make it a template parameterized by thread functors
[SVN r81079]
2012-10-29 00:36:06 +00:00
Vicente J. Botet Escriba
ec1241a6d8 Thread: Added thread_joiner
[SVN r81074]
2012-10-28 17:55:32 +00:00
Vicente J. Botet Escriba
ae819901ab Thread: Added scoped_thread
[SVN r81073]
2012-10-28 17:53:42 +00:00
Vicente J. Botet Escriba
3c0294cf3a Thread: added first version of synchronized_value
[SVN r81072]
2012-10-28 17:43:40 +00:00
Vicente J. Botet Escriba
0ae81b8d4c Thread: merge [81032][81034]
[SVN r81035]
2012-10-21 11:56:52 +00:00
Vicente J. Botet Escriba
21bc767445 Thread: remove include iostream
[SVN r81034]
2012-10-21 09:26:58 +00:00
Vicente J. Botet Escriba
47b6368ef7 Thread: merge 81024
[SVN r81032]
2012-10-21 06:37:51 +00:00
Vicente J. Botet Escriba
05f02e1476 Thread: merge 80986
[SVN r81024]
2012-10-20 15:19:13 +00:00
Vicente J. Botet Escriba
a3098b5dfd Thread: Added BOOST_THREAD_DONT_PROVIDE_THREAD_EQ, BOOST_THREAD_DONT_USE_DATETIME and forbid their use when defined + Added BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION and future<>::then + Go towards don't throwing from the cpp files (refactor start_thread, join + Added #define BOOST_THREAD_VERSION 2 for the tests that runs only with version 2
[SVN r81023]
2012-10-20 14:05:32 +00:00
Vicente J. Botet Escriba
23ea174056 Thread: update doc fixes
[SVN r80999]
2012-10-16 17:48:12 +00:00
Vicente J. Botet Escriba
bd69c9382f Thread: ref #7461
[SVN r80986]
2012-10-14 16:32:41 +00:00
Vicente J. Botet Escriba
ce19b13c43 Thread: merged 80966
[SVN r80985]
2012-10-14 15:26:00 +00:00
Vicente J. Botet Escriba
b47f43df59 Thread: Rollback SIG_ATOMIC_MAX change for once.hpp. ref #7499
[SVN r80966]
2012-10-12 00:01:30 +00:00
Vicente J. Botet Escriba
8262d61ff5 Thread: Merge 80757
[SVN r80955]
2012-10-11 15:56:21 +00:00
Vicente J. Botet Escriba
e9217d02f0 Thread: remove some minor warnings
[SVN r80854]
2012-10-04 21:57:18 +00:00
Vicente J. Botet Escriba
6741c8420a Thread: define BOOST_THREAD_PLATFORM_PTHREAD also in windows and restrict it BOOST_NO_SFINAE_EXPR is not defined
[SVN r80853]
2012-10-04 21:55:03 +00:00
Vicente J. Botet Escriba
fe45847841 Thread: remove warning
[SVN r80848]
2012-10-04 17:09:22 +00:00
Vicente J. Botet Escriba
5d13b87dd3 Thread: constraint these test to run only when BOOST_THREAD_USES_CHRONO is defined
[SVN r80847]
2012-10-04 17:08:23 +00:00
Vicente J. Botet Escriba
e1f5fbdc33 Thread: fix typo introduced while making get_id inline on posix
[SVN r80845]
2012-10-04 16:50:46 +00:00
Vicente J. Botet Escriba
b342cf683b Thread: Protect the static assert to catch bug with gcc-4.4
[SVN r80832]
2012-10-03 20:14:15 +00:00
Vicente J. Botet Escriba
e94946cc8c Thread: Added static assert to catch bug with gcc-4.4
[SVN r80830]
2012-10-03 18:47:53 +00:00
Vicente J. Botet Escriba
8604ca1b85 Thread: Fix bug with gcc4.4, prepare change to v3 by default
[SVN r80824]
2012-10-03 05:45:35 +00:00
Vicente J. Botet Escriba
9847f57ce7 Thread: Update doc
[SVN r80823]
2012-10-03 05:43:38 +00:00
Vicente J. Botet Escriba
74e2c4cbcb Thread: Fixed cout access issue
[SVN r80821]
2012-10-02 21:11:29 +00:00
Vicente J. Botet Escriba
4d013af927 Thread: merge from trunk
[SVN r80801]
2012-10-01 00:24:05 +00:00
Vicente J. Botet Escriba
7b54159af3 Thread: Make use of BOOST_TRY family macros on win32 code
[SVN r80799]
2012-09-30 23:46:00 +00:00
Vicente J. Botet Escriba
16ad9c868e Thread: make the code of tests set_rvalue and make_future more portable
[SVN r80789]
2012-09-30 17:33:56 +00:00
Vicente J. Botet Escriba
26f4ad3db2 Thread: try to fix some issues with packaged_task with signature parameters
[SVN r80783]
2012-09-30 14:31:52 +00:00
Vicente J. Botet Escriba
715928e143 Thread: Allow BOOST_THREAD_PROVIDES_VARIADIC_THREAD only if BOOST_NO_CXX11_HDR_TUPLE is defined + remove some -ansi flags tha make EXPERIMENTAL_CXX0X to be not defined
[SVN r80766]
2012-09-29 23:35:29 +00:00
Hartmut Kaiser
40d694e893 Thread: adding inline keyword to avoid linker errors
[SVN r80765]
2012-09-29 21:42:36 +00:00
Vicente J. Botet Escriba
4d84fb97c9 Thread: constrain make_future example to run when rvalues references are supported.
[SVN r80763]
2012-09-29 20:54:24 +00:00
Vicente J. Botet Escriba
ab7bb7a82d Thread: try to fix regression on test_once
[SVN r80759]
2012-09-29 18:22:21 +00:00
Vicente J. Botet Escriba
171be40a1f Thread: rollback preceding change and apply patch spliting the assembles so that each instruction is on one line.
[SVN r80757]
2012-09-29 16:53:11 +00:00
Vicente J. Botet Escriba
18d4a8a0f8 Thread: Added missing file
[SVN r80756]
2012-09-29 16:36:19 +00:00
Vicente J. Botet Escriba
dedaa7e617 Thread: version 4: Added variadic templates for packed_task cons, async, thread cons + added make_future + future::get() can be called just once
[SVN r80755]
2012-09-29 16:31:27 +00:00
Jürgen Hunold
6173ae42a9 Fix: C4251 warnings from msvc
Suppress those from the standard library.
Make handle_manager visible via BOOST_THREAD_DECL.

[SVN r80669]
2012-09-23 14:33:50 +00:00
Vicente J. Botet Escriba
2d8852199b Thread: Merge from trunk
[SVN r80668]
2012-09-23 12:38:00 +00:00
Vicente J. Botet Escriba
792604127e Thread: Added missing what() virtual function of future_error
[SVN r80594]
2012-09-19 00:16:08 +00:00
Vicente J. Botet Escriba
81d0aaf7bc Thread: Added missing what() virtual function of future_error
[SVN r80593]
2012-09-18 23:10:51 +00:00
Vicente J. Botet Escriba
26c495e5b3 Thread: Complete future reference documentation
[SVN r80570]
2012-09-18 06:08:11 +00:00
Vicente J. Botet Escriba
a1f8717170 Thread: fix some typos
[SVN r80565]
2012-09-17 21:30:48 +00:00
Vicente J. Botet Escriba
460a38b994 Thread: (posix) Make use of BOOST_TRY family macros
[SVN r80544]
2012-09-16 18:50:17 +00:00
Vicente J. Botet Escriba
dbefae706c Thread: Fixed windows part of 7360
[SVN r80533]
2012-09-15 14:28:49 +00:00
Vicente J. Botet Escriba
a33e82af60 Thread: fix type on UpgradeLockable requirements
[SVN r80517]
2012-09-13 19:02:37 +00:00
Vicente J. Botet Escriba
12a1c7c71c Thread: merge from trunk
[SVN r80516]
2012-09-13 18:57:04 +00:00
Vicente J. Botet Escriba
8f283b3c2b Thread: fixe typo using std instead of boost.
[SVN r80498]
2012-09-11 22:14:52 +00:00
Vicente J. Botet Escriba
b1ae3a98e8 Thread: Remove temporarly the check on n_alive until I use a movable class
[SVN r80497]
2012-09-11 21:54:06 +00:00
Vicente J. Botet Escriba
fcaaa68f87 Thread: Apply patch for 7360
[SVN r80496]
2012-09-11 21:52:52 +00:00
Vicente J. Botet Escriba
89e944914b Thread: Merged from trunk : 1.52
[SVN r80476]
2012-09-09 19:39:44 +00:00
Vicente J. Botet Escriba
b7622b7407 Thread: complete update for 7345 on windows.
[SVN r80475]
2012-09-09 19:26:47 +00:00
Vicente J. Botet Escriba
a56358c8f8 Thread: Apply patch for 6931.
[SVN r80474]
2012-09-09 19:25:03 +00:00
Vicente J. Botet Escriba
dafe4bea1a Thread: force SIG_ATOMIC_MAX with __STDC_LIMIT_MACROS
[SVN r80466]
2012-09-09 14:48:18 +00:00
Vicente J. Botet Escriba
408a6cb70e Thread: fix typo s/Rational/Rationale/
[SVN r80464]
2012-09-09 13:09:15 +00:00
Vicente J. Botet Escriba
97c0ddbee4 Thread: updated history
[SVN r80461]
2012-09-09 12:46:49 +00:00
Vicente J. Botet Escriba
330502ea1e Thread: Manage with statefull allocators and call destroy on the task object: #7349 and #7350
[SVN r80460]
2012-09-09 12:41:31 +00:00
Vicente J. Botet Escriba
662118b5c6 Thread: Remove BOOST_THREAD_DONT_USE_SYSTEM and update documentation to manage with 7336
[SVN r80459]
2012-09-09 12:35:37 +00:00
Vicente J. Botet Escriba
7bc8c437ab Thread: merge from trunk: 1.52
[SVN r80450]
2012-09-08 14:59:26 +00:00
Vicente J. Botet Escriba
8bee2291fd Thread: start adding noexcept to recursive_mutex::try_lock. Uncomment needed after checking on windows
[SVN r80449]
2012-09-08 14:18:43 +00:00
Vicente J. Botet Escriba
39c4db3e66 Thread: cleanup include
[SVN r80448]
2012-09-08 14:18:14 +00:00
Vicente J. Botet Escriba
749b1034f9 Thread: test async with moveonly functors.
[SVN r80447]
2012-09-08 14:16:07 +00:00
Vicente J. Botet Escriba
735102d4a0 Thread: update doc with async and notify_all_at_thread_exit referece doc
[SVN r80446]
2012-09-08 14:12:05 +00:00
Vicente J. Botet Escriba
5e30d7486e Thread: Try to fix move limitation on hpux: 7329
[SVN r80439]
2012-09-08 06:43:07 +00:00
Vicente J. Botet Escriba
71f864bc5c Thread: Added notify_all_at_thread_exit+join can throw conditionally if not joinable + detach is no more noexcept
[SVN r80351]
2012-09-01 17:10:16 +00:00
Vicente J. Botet Escriba
b31c1a11d5 Thread: Avoid double definition of BOOST_THREAD_DONT_USE_CHRONO
[SVN r80342]
2012-08-31 23:27:20 +00:00
Vicente J. Botet Escriba
bf03f733a6 Thread: Avoid ambiguity on thread symbol
[SVN r80323]
2012-08-30 17:30:25 +00:00
Vicente J. Botet Escriba
ca04d699bc Thread:7280: Added noexcep to future_category
[SVN r80238]
2012-08-26 18:18:03 +00:00
Vicente J. Botet Escriba
530aaaae38 Thread: 7045: make boost_thread don't depend on boost_chrono for win and 2797: armonize win behavior with posix one.
[SVN r80236]
2012-08-26 15:17:39 +00:00
Vicente J. Botet Escriba
36970f3240 Thread: take care of #7272 warning removal
[SVN r80235]
2012-08-26 13:05:10 +00:00
Vicente J. Botet Escriba
7c97dc8131 Thread: take care of #7272 warning removal
[SVN r80203]
2012-08-25 13:21:21 +00:00
Vicente J. Botet Escriba
a7336c2c5e Thread: update doc
[SVN r80202]
2012-08-25 13:07:54 +00:00
Vicente J. Botet Escriba
8866935d0b Thread: doc shared mutex lack of priority 7284
[SVN r80201]
2012-08-25 13:06:41 +00:00
Vicente J. Botet Escriba
4f06c2392b Thread: update tss doc to take care of #2361 and #3837
[SVN r80198]
2012-08-25 12:28:42 +00:00
Vicente J. Botet Escriba
677113cfbe Thread: fix win regression
[SVN r80152]
2012-08-23 06:25:07 +00:00
Vicente J. Botet Escriba
a01faf1bb8 Thread: fix win regression
[SVN r80134]
2012-08-22 06:12:46 +00:00
Vicente J. Botet Escriba
050b43757f Thread: remove includes using lib/thread
[SVN r80125]
2012-08-21 21:30:00 +00:00
Vicente J. Botet Escriba
448c4b21b5 Thread: added test_3837
[SVN r80124]
2012-08-21 21:29:04 +00:00
Vicente J. Botet Escriba
84d8dea5ba Thread: Add dependency from boost_thread to boost_date_time.
[SVN r80123]
2012-08-21 21:22:35 +00:00
Vicente J. Botet Escriba
5fa5b680f0 Thread: remove dependency from boo_thread to boost_chrono
[SVN r80122]
2012-08-21 21:20:41 +00:00
Vicente J. Botet Escriba
5b26427079 Thread: It seems that the csignal inclusion is failing in all testers, so comment it
[SVN r80082]
2012-08-19 15:41:26 +00:00
Vicente J. Botet Escriba
d426d2ca88 Thread: try to fix 5752
[SVN r80078]
2012-08-18 14:43:06 +00:00
Vicente J. Botet Escriba
2e5bc32b33 Thread: try to fix 7238
[SVN r80076]
2012-08-18 11:26:51 +00:00
Vicente J. Botet Escriba
b0b975e8ef Thread fixes some doc typos
[SVN r80075]
2012-08-18 10:33:31 +00:00
Vicente J. Botet Escriba
1f4df63577 Thread: manage with #5274
[SVN r80053]
2012-08-15 21:29:14 +00:00
Vicente J. Botet Escriba
cf7c218a65 Thread: manage #7173
[SVN r80052]
2012-08-15 20:25:03 +00:00
Vicente J. Botet Escriba
1a1751b45d Thread fix inspecion report errors
[SVN r80049]
2012-08-15 13:11:47 +00:00
Vicente J. Botet Escriba
0354c2fcc3 Thread: apply fix for 7220
[SVN r80041]
2012-08-15 09:59:32 +00:00
Vicente J. Botet Escriba
c4420d7591 Thread: merge fix for #6174
[SVN r80040]
2012-08-15 09:54:21 +00:00
Vicente J. Botet Escriba
1679cd2fff Thread: Added date trace for 6130 test
[SVN r80002]
2012-08-13 12:04:17 +00:00
Vicente J. Botet Escriba
32db9f2e71 Thread: Added date trace for 6130 test
[SVN r80001]
2012-08-13 12:03:39 +00:00
Vicente J. Botet Escriba
6b98bee683 Thread: Added test for 7160 ticket
[SVN r79991]
2012-08-12 19:20:35 +00:00
Vicente J. Botet Escriba
7de77cf13c Thread: fixes for inspection report
[SVN r79985]
2012-08-12 18:33:11 +00:00
Vicente J. Botet Escriba
8334f4e68a Thread: name type for pthread/once epoch so that we can choose better an /atomic/ type for it
[SVN r79984]
2012-08-12 18:31:09 +00:00
Vicente J. Botet Escriba
1ac7e7129d Thread: refix 6174
[SVN r79980]
2012-08-12 16:36:40 +00:00
Vicente J. Botet Escriba
daec1268f9 Thread: Added async function
[SVN r79979]
2012-08-12 16:31:21 +00:00
Andrey Semashev
6ef2dade3a Merged changes from trunk.
[SVN r79794]
2012-07-29 08:44:22 +00:00
Hartmut Kaiser
c47bd34760 Threads: fixing a bad preprocessor directive
[SVN r79782]
2012-07-28 14:06:27 +00:00
Andrey Semashev
0d9ebfc820 Fixed compilation when Boost.Chrono is disabled by user.
[SVN r79753]
2012-07-26 08:08:06 +00:00
Vicente J. Botet Escriba
c594f5d9ae Thread: update changes
[SVN r79408]
2012-07-10 20:58:07 +00:00
Vicente J. Botet Escriba
3332d8df66 Thread: fix typo - 7117
[SVN r79407]
2012-07-10 20:50:40 +00:00
Vicente J. Botet Escriba
852c173c96 Thread: fix typo - 7117
[SVN r79406]
2012-07-10 20:47:52 +00:00
Vicente J. Botet Escriba
a73cf83971 Thread: Merge from trunk
[SVN r79397]
2012-07-09 22:13:44 +00:00
Vicente J. Botet Escriba
bcf30f2dfc Thread: cleanup no-exceptions on windows
[SVN r79384]
2012-07-09 16:50:35 +00:00
Vicente J. Botet Escriba
2ea1aec7fd Thread: cleanup no-exceptions on windows
[SVN r79383]
2012-07-09 16:46:01 +00:00
Vicente J. Botet Escriba
67a5a6f39e Thread: merge from trunk
[SVN r79373]
2012-07-09 05:55:01 +00:00
Vicente J. Botet Escriba
dc5a26c5d3 Thread: Jamfile cleanup
[SVN r79366]
2012-07-08 19:10:37 +00:00
Vicente J. Botet Escriba
3c8f164371 Thread: no-exception cleanup
[SVN r79365]
2012-07-08 18:53:34 +00:00
Vicente J. Botet Escriba
93c14be188 Thread: no-exceptions cleanup
[SVN r79361]
2012-07-08 17:38:18 +00:00
Vicente J. Botet Escriba
b305cc29fc Thread: Added some changes to make it work with BOOST_NO_EXCEPTIONS
[SVN r79347]
2012-07-08 09:33:13 +00:00
Vicente J. Botet Escriba
c2001fb9d2 Thread: changed assembler for interlocked_bit_test_and_set compatible hp
[SVN r79337]
2012-07-07 14:43:18 +00:00
Vicente J. Botet Escriba
d3a8321be0 Thread: remove warning wait_until
[SVN r79336]
2012-07-07 14:41:02 +00:00
Vicente J. Botet Escriba
8bfd588b4c Thread: remove warning attribute size
[SVN r79335]
2012-07-07 14:38:53 +00:00
Vicente J. Botet Escriba
5268fd3749 Thread: Added __MINGW64_VERSION_MAJOR when __MINGW64__ is not defined
[SVN r79334]
2012-07-07 14:37:07 +00:00
Vicente J. Botet Escriba
19bbd85d9d Thread: rollback bad workaround BOOST_THREAD_WAIT_BUG - 7089
[SVN r79327]
2012-07-07 10:20:39 +00:00
Vicente J. Botet Escriba
deca987299 Thread: Fix 7074
[SVN r79288]
2012-07-05 16:42:01 +00:00
Anthony Williams
1a4eed3b69 Initialization of current_thread_tls_key is direct from macro again to re-enable static initialization
[SVN r79239]
2012-07-03 08:10:41 +00:00
Vicente J. Botet Escriba
348bd080ef Thread: remove unused file: shared_mutex.cpp 7044
[SVN r79238]
2012-07-03 06:20:41 +00:00
Vicente J. Botet Escriba
1214f99227 Thread: apply patch in 7052
[SVN r79237]
2012-07-02 21:58:56 +00:00
Vicente J. Botet Escriba
51530e03a5 Thread: Added possible missing vector file in some platforms
[SVN r79185]
2012-06-30 09:59:57 +00:00
Vicente J. Botet Escriba
bca4c3d5fa Thread: Added other fixed tickets in history
[SVN r79031]
2012-06-21 21:26:35 +00:00
Vicente J. Botet Escriba
66263dd7b3 Thread: Added other fixed tickets
[SVN r79030]
2012-06-21 21:23:35 +00:00
Vicente J. Botet Escriba
9e6384bf79 Thread: merge from trunk to fix some minor bugs
[SVN r78973]
2012-06-16 21:10:08 +00:00
Vicente J. Botet Escriba
6b0ce64d5e Thread: Fix max macro issue on Windows
[SVN r78920]
2012-06-13 06:34:22 +00:00
Vicente J. Botet Escriba
3b080058ed Thread: rolled back breaking changes on windows.
[SVN r78919]
2012-06-13 06:00:38 +00:00
Vicente J. Botet Escriba
00996a2a02 Thread: rollback unchecked an errored change
[SVN r78863]
2012-06-09 10:09:51 +00:00
Vicente J. Botet Escriba
c0299f4a1e Thread: Added missing BOOST_THREAD_DECL
[SVN r78823]
2012-06-05 21:19:06 +00:00
Vicente J. Botet Escriba
e09105de98 Thread: fix TIME_UTC, WINVER, constexpr for tags, and don't use local files
[SVN r78802]
2012-06-03 18:11:52 +00:00
Anthony Williams
dcd544082e Merged boost.thread from trunk
[SVN r78543]
2012-05-22 17:03:15 +00:00
Dave Abrahams
1013ce68c1 Replace all uses of boost/utility.hpp with more-granular includes. Solves modularization dependency nightmare.
[SVN r78502]
2012-05-18 04:44:04 +00:00
Vicente J. Botet Escriba
aea84b03fc Thread: link with Boost.Chrono for vacpp-11.1
[SVN r78451]
2012-05-13 08:46:43 +00:00
Anthony Williams
7608db4b0e Combine scoped enum emulation from thread library into detail/scoped_enum_emulation.hpp
[SVN r78407]
2012-05-10 17:06:15 +00:00
Anthony Williams
62f1c4b086 Reinstate abi prefix/suffix headers
[SVN r78399]
2012-05-10 07:30:41 +00:00
Vicente J. Botet Escriba
ab6864f3b4 Thread: try to fix ticket 6130 for linux systems
[SVN r78285]
2012-04-30 20:23:56 +00:00
Vicente J. Botet Escriba
b8bd80a5f4 Thread: Use NO_COPYABLE macro
[SVN r78280]
2012-04-30 16:06:04 +00:00
Vicente J. Botet Escriba
fffc5ddd1f Thread: Added some traces to catch spourious issue
[SVN r78279]
2012-04-30 16:05:24 +00:00
Vicente J. Botet Escriba
cd4c858048 Thread: Added some traces to catch spourious issue
[SVN r78278]
2012-04-30 16:04:22 +00:00
Vicente J. Botet Escriba
3fb1bd3d1d Thread: warning removal
[SVN r78277]
2012-04-30 16:03:30 +00:00
Vicente J. Botet Escriba
75aff7f1a6 Thread: Try to fix spourious issue
[SVN r78276]
2012-04-30 16:01:19 +00:00
Vicente J. Botet Escriba
3f3c5c8ac5 Thread: warning removal
[SVN r78275]
2012-04-30 16:00:29 +00:00
Vicente J. Botet Escriba
40b66a83f7 Thread: removed warning
[SVN r78254]
2012-04-29 14:27:43 +00:00
Vicente J. Botet Escriba
0b15d66dc0 Thread: Added use of macro BOOST_THREAD_MAKE_RV_REF and some traces to try to solve PGI regression test
[SVN r78243]
2012-04-28 16:11:03 +00:00
Vicente J. Botet Escriba
ceacda6c6a Thread: Refactor the no-copyable classes using the macro BOOST_THREAD_NO_COPYABLE
[SVN r78240]
2012-04-28 12:25:28 +00:00
Vicente J. Botet Escriba
0a22ac9209 Thread: Add a workaround for the bug identified in ticket 6130 by adding some microseconds to the time to wait
[SVN r78239]
2012-04-28 12:24:08 +00:00
Vicente J. Botet Escriba
ba1d54d672 Thread: inhibit allocators on wince as there is a bug on Boost.Intrusive
[SVN r78226]
2012-04-28 00:08:53 +00:00
Vicente J. Botet Escriba
b5a18dc71a Thread: Boost.Chrono seems to work on vacpp 11.1
[SVN r78225]
2012-04-27 23:29:01 +00:00
Vicente J. Botet Escriba
4a0141511d Thread: Boost.Chrono seems to work on vacpp 11.1
[SVN r78224]
2012-04-27 23:08:24 +00:00
Vicente J. Botet Escriba
f0a6e49984 Thread: Try to fix some errors with vacpp
[SVN r78222]
2012-04-27 22:24:17 +00:00
Vicente J. Botet Escriba
f60e1d1230 Thread: Try to fix some spourious error
[SVN r78197]
2012-04-25 21:55:07 +00:00
Vicente J. Botet Escriba
625db78abf Thread: more move semantics refactoring cleanup
[SVN r78139]
2012-04-22 16:33:46 +00:00
Vicente J. Botet Escriba
b470ffdb56 Thread: Added macro BOOST_THREAD_DCL_MOVABLE to mask has_move_emulation_enabled_aux specialization
[SVN r78123]
2012-04-22 08:12:27 +00:00
Vicente J. Botet Escriba
78095afdbc Thread: Fix issue with macro BOOST_THREAD_RV_REF and the use of templates as arguments, see with Sun compiler
[SVN r78086]
2012-04-19 22:19:52 +00:00
Vicente J. Botet Escriba
e83cdc6721 Thread: Change to version 3 and don't deprecate legacy time related functions, even if they are not part of the concepts since version 3
[SVN r78029]
2012-04-16 20:49:18 +00:00
Vicente J. Botet Escriba
7ba000fe45 Thread: Set by default to don't use Boost.Move
[SVN r77994]
2012-04-15 12:29:33 +00:00
Vicente J. Botet Escriba
cae6a36c19 Thread: fix some macros using old move emilation
[SVN r77985]
2012-04-15 09:55:25 +00:00
Vicente J. Botet Escriba
8549895373 Thread: Make use of the new macros to reduce the code duplication-IV
[SVN r77946]
2012-04-13 09:39:17 +00:00
Vicente J. Botet Escriba
efa907881e Thread: Make use of the new macros to reduce the code duplication-III
[SVN r77941]
2012-04-12 22:59:23 +00:00
Vicente J. Botet Escriba
744cae8270 Thread: Make use of the new macros to reduce the code duplication
[SVN r77939]
2012-04-12 20:32:20 +00:00
Vicente J. Botet Escriba
28899243b1 Thread: symplify additonaly the conditional code + fix some spurious regression errors
[SVN r77933]
2012-04-12 11:12:23 +00:00
Vicente J. Botet Escriba
267288ba19 Thread! remove unused param warning
[SVN r77930]
2012-04-12 08:07:00 +00:00
Vicente J. Botet Escriba
3487d05fac Thread: Fix typo
[SVN r77929]
2012-04-12 08:06:13 +00:00
Vicente J. Botet Escriba
031186a8e6 Thread: Add some macros to simplify the conditional code in particular the one related to mmove semantics+ fix some minor regression issues
[SVN r77928]
2012-04-11 23:42:26 +00:00
Vicente J. Botet Escriba
f970c9fddc Thread: remove some warnings + rename BOOST_EXPLICIT_MOVE by BOOST_THREAD_MAKE_RV_REF
[SVN r77918]
2012-04-11 17:16:45 +00:00
Vicente J. Botet Escriba
e9ceaaa2bb Thread: Set examples exmplcit
[SVN r77888]
2012-04-10 16:22:51 +00:00
Vicente J. Botet Escriba
0e7c436df5 Thread: Added container tests
[SVN r77887]
2012-04-10 16:21:43 +00:00
Vicente J. Botet Escriba
745e23f2c3 Thread: move specialization of uses_allocator
[SVN r77885]
2012-04-10 13:29:36 +00:00
Vicente J. Botet Escriba
1f7b8a6583 Thread: Added -ansi -permissive on some compilers
[SVN r77884]
2012-04-10 12:33:51 +00:00
Vicente J. Botet Escriba
b2790c6df5 Thread: Added pt test constructor from const functor + pt allocator ctor free fct+ cleanup of other tests
[SVN r77877]
2012-04-10 01:37:18 +00:00
Vicente J. Botet Escriba
f5e3c1c348 Thread: Added pt func_ctor test + update some test to pass Sun compiler regression
[SVN r77876]
2012-04-10 00:24:07 +00:00
Vicente J. Botet Escriba
ba955f003e Thread: Fix packaged_task callable copy
[SVN r77875]
2012-04-10 00:14:12 +00:00
Vicente J. Botet Escriba
75e0ffbbce Thread: rollback the last changes in packaged_task
[SVN r77870]
2012-04-09 23:21:16 +00:00
Vicente J. Botet Escriba
9168dd7d1d Thread: fix commit error
[SVN r77860]
2012-04-09 19:23:37 +00:00
Vicente J. Botet Escriba
ee5f871f1a Thread: fix commit error
[SVN r77857]
2012-04-09 18:56:39 +00:00
Vicente J. Botet Escriba
c896c8fda4 Thread: fix commit error
[SVN r77853]
2012-04-09 17:52:46 +00:00
Vicente J. Botet Escriba
0e895a1e28 Thread: Added packaged_task::reste() + more tests
[SVN r77852]
2012-04-09 17:18:39 +00:00
Vicente J. Botet Escriba
d95081094f Thread: remove some warnings
[SVN r77849]
2012-04-09 15:26:40 +00:00
Vicente J. Botet Escriba
011dda9816 Thread: Added packaged_task ctor allocator + result_type + Fix issue signaled on the ML with task_object(task_object const&) in presence of task_object(task_object &&)
[SVN r77845]
2012-04-08 23:51:07 +00:00
Vicente J. Botet Escriba
34c377328f Thread: Added some packaged_task tests
[SVN r77844]
2012-04-08 23:24:19 +00:00
Vicente J. Botet Escriba
382204f702 Thread: Make use of the boost version of use_allocator
[SVN r77843]
2012-04-08 22:40:37 +00:00
Vicente J. Botet Escriba
19aed55e52 Thread: Fix type
[SVN r77841]
2012-04-08 20:56:34 +00:00
Vicente J. Botet Escriba
9d1e1fb64a Thread: Activate share mutex upwards conversions tests
[SVN r77839]
2012-04-08 19:23:34 +00:00
Vicente J. Botet Escriba
d75cda0cc3 Thread: Provided an alternative implementation for thread::id using pthread_t and Windows Thread Id
[SVN r77838]
2012-04-08 19:22:38 +00:00
Vicente J. Botet Escriba
a4c7f68320 Thread: Added needed header
[SVN r77836]
2012-04-08 18:57:07 +00:00
Vicente J. Botet Escriba
547431da0b Thread: fix typo
[SVN r77825]
2012-04-08 07:57:32 +00:00
Vicente J. Botet Escriba
c3fdc098fe Thread: Try to fix some failing tests on sun
[SVN r77806]
2012-04-07 07:59:23 +00:00
Vicente J. Botet Escriba
6ed276190d Thread: rename macros and try to fix some failing sun test
[SVN r77789]
2012-04-05 22:39:22 +00:00
Vicente J. Botet Escriba
59265265d9 Thread: 6342: Adapt the one_flag and call_once to the c++11 interface
[SVN r77767]
2012-04-04 20:01:11 +00:00
Vicente J. Botet Escriba
8d9370b005 Thread: Try to pass these tests on VACPP
[SVN r77766]
2012-04-04 19:56:56 +00:00
Vicente J. Botet Escriba
fd97c6e7a7 Thread: Try to pass these test on Sun using BOOST_EXPLICIT_MOVE
[SVN r77754]
2012-04-04 15:15:11 +00:00
Vicente J. Botet Escriba
297da0745f Thread: Try to pass these test on Sun using BOOST_EXPLICIT_MOVE
[SVN r77753]
2012-04-04 15:14:05 +00:00
Vicente J. Botet Escriba
cb231e02a6 Thread: Try to pass these test on Sun using BOOST_EXPLICIT_MOVE
[SVN r77751]
2012-04-03 20:57:24 +00:00
Vicente J. Botet Escriba
298b51fefa Thread: Check if adding BOOST_EXPLICIT_MOVE helps on Sun
[SVN r77729]
2012-04-02 22:49:11 +00:00
Vicente J. Botet Escriba
80befa1c94 Thread: rollback 76581 partialy so that no link with boost chrono is done on vaccp
[SVN r77728]
2012-04-02 22:33:05 +00:00
Vicente J. Botet Escriba
11dce20534 Thread: Remove duplicated file #3160
[SVN r77719]
2012-04-02 16:37:53 +00:00
Vicente J. Botet Escriba
56bd079f96 Thread: Added call to terminate if joinable for #6266 and #6269
[SVN r77718]
2012-04-02 16:32:33 +00:00
Vicente J. Botet Escriba
733b49ae42 Thread: Fix Jamfile removing not needed source shared_mutex.cpp
[SVN r77705]
2012-04-01 22:14:06 +00:00
Vicente J. Botet Escriba
08ed4c4201 Thread: Added shared mutex upwards conversion + configuration macros
[SVN r77704]
2012-04-01 21:52:47 +00:00
Vicente J. Botet Escriba
09d5125278 Thread: Fix typos due to copy/paste
[SVN r77701]
2012-04-01 20:38:31 +00:00
Vicente J. Botet Escriba
6e1a3f3c27 Thread: Added specific macros for futures and importing container specific into boost
[SVN r77687]
2012-04-01 15:51:18 +00:00
Vicente J. Botet Escriba
5b3743d9a6 Thread: Split test with and wothout args
[SVN r77686]
2012-04-01 15:48:56 +00:00
Vicente J. Botet Escriba
ec135b1b8e Thread: Added missing file
[SVN r77684]
2012-04-01 09:14:50 +00:00
Vicente J. Botet Escriba
60e34cff11 Thread: Make use of the generic shared implementation for the missing features in windows.
[SVN r77668]
2012-03-31 15:38:56 +00:00
Vicente J. Botet Escriba
da8dc9f5aa Thread: Add the possibility to use the more complete and generic implementation of shared_mutex in windows.
[SVN r77667]
2012-03-31 15:37:44 +00:00
Vicente J. Botet Escriba
27aa44acb5 Thread: Added promise allocator ctor + more tests
[SVN r77666]
2012-03-31 15:19:22 +00:00
Vicente J. Botet Escriba
ff1d051359 Thread: Added reverse_lock
[SVN r77662]
2012-03-31 08:39:21 +00:00
Vicente J. Botet Escriba
85e32534fa Thread: Added shared_lock_guard
[SVN r77661]
2012-03-31 08:06:57 +00:00
Vicente J. Botet Escriba
bc49b7d03a Thread: Update doc with a lot of changes to follow the updated code
[SVN r77660]
2012-03-31 07:37:59 +00:00
Vicente J. Botet Escriba
ee97068208 Thread Fix incoherent BOOST_NOEXCEPT prototype
[SVN r77659]
2012-03-31 07:16:20 +00:00
Vicente J. Botet Escriba
0f7e069dd9 Thread: Added explicit int conversion from lock should fail
[SVN r77658]
2012-03-31 06:52:55 +00:00
Vicente J. Botet Escriba
3c3c6d5efe Thread: Fix warning + added DEPRECATED tag
[SVN r77655]
2012-03-30 19:16:51 +00:00
Vicente J. Botet Escriba
f163054557 Thread: Added more noexcept
[SVN r77640]
2012-03-30 04:46:47 +00:00
Vicente J. Botet Escriba
fb80bea056 Thread: Disable The use of Boost.Thread for SunPro compiler
[SVN r77612]
2012-03-28 20:40:31 +00:00
Vicente J. Botet Escriba
abad5c3028 Thread: Added BOOST_EXPLICIT_MOVE
[SVN r77588]
2012-03-27 18:22:30 +00:00
Vicente J. Botet Escriba
d0c164220d Thread: DOn't use Boost.Test when not needed to avoid issues on Sun
[SVN r77586]
2012-03-27 17:26:10 +00:00
Vicente J. Botet Escriba
34b1a86a68 Thread: Update F_pass and Frvalue tests for compilers that doesn't support rvalue references or delete constructors.
[SVN r77551]
2012-03-25 22:31:11 +00:00
Vicente J. Botet Escriba
06f5da7f5b Thread: cleanup
[SVN r77550]
2012-03-25 21:25:20 +00:00
Vicente J. Botet Escriba
1e80ccb8d3 Thread: Protect uses of Boost.Chrono for compilers don't providing support for
[SVN r77460]
2012-03-21 21:05:26 +00:00
Vicente J. Botet Escriba
8ad34a689a Thread: Fixed error on promise v2 + added tests (share)
[SVN r77443]
2012-03-20 23:49:31 +00:00
Vicente J. Botet Escriba
a421e10e3b Thread: Comment not yet commited tests
[SVN r77427]
2012-03-20 07:48:36 +00:00
Vicente J. Botet Escriba
1c4b42bb95 Thread: Make test names shorter
[SVN r77401]
2012-03-19 12:12:21 +00:00
Vicente J. Botet Escriba
bba3be457b Thread: Fix missing include
[SVN r77399]
2012-03-19 06:49:13 +00:00
Vicente J. Botet Escriba
3abfbb8ba1 Thread: Added upgrade_mutex on windows
[SVN r77396]
2012-03-18 23:42:23 +00:00
Vicente J. Botet Escriba
331a35070c Thread: comment not yet committed examples
[SVN r77394]
2012-03-18 22:55:13 +00:00
Vicente J. Botet Escriba
99ad690382 Thread: Added Chrono related functions to exclusive lock+ upgrade_mutex typedef
[SVN r77393]
2012-03-18 22:49:24 +00:00
Vicente J. Botet Escriba
4301b21702 Thread: Added LOCK::move() member function when no RVALUE is available (Useful for Sun compiler to force move semantics) + possibility to have explicit lock conversions+chrono timed related unique_lock constructor from upgrade_lock
[SVN r77392]
2012-03-18 22:35:11 +00:00
Vicente J. Botet Escriba
fceab582fe Thread: Added future/shared/future/promise/packaged_task::move() member function when no RVALUE is available (Useful for Sun compiler to force move semantics)
[SVN r77391]
2012-03-18 22:06:44 +00:00
Vicente J. Botet Escriba
e8a4ed40a5 Thread: Make test names shorter + Added more tests on locks
[SVN r77388]
2012-03-18 21:27:30 +00:00
Vicente J. Botet Escriba
b698c1437b Thread: Update test to run
[SVN r77384]
2012-03-18 19:54:39 +00:00
Vicente J. Botet Escriba
14cea92e06 Thread: Added thread::move member function when BOOST_THREAD_USES_MOVE is defined (Useful for Sun compiler)
[SVN r77379]
2012-03-18 18:35:20 +00:00
Vicente J. Botet Escriba
3a8e04cac6 Thread: Make test names shorter + Added some examples of shared mutex and tests
[SVN r77378]
2012-03-18 18:21:45 +00:00
Vicente J. Botet Escriba
5b01721440 Thread: Add time chrono related functions to shared_mutex(win) + activate tests
[SVN r77376]
2012-03-18 17:29:33 +00:00
Vicente J. Botet Escriba
aad2b35ac9 Thread: Fix bug on time related functions that should base the _for functions on the until_ ones
[SVN r77375]
2012-03-18 17:26:30 +00:00
Vicente J. Botet Escriba
f8371daeb8 Thread: Avoid some warnings as unused variable it and warning C4275: non dll-interface class 'std::logic_error' used as base for dll-interface class 'boost::future_error'
[SVN r77360]
2012-03-17 14:42:36 +00:00
Vicente J. Botet Escriba
74519977fd Thread: Avoid warning boost/bind/bind.hpp(392) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
[SVN r77356]
2012-03-17 12:47:54 +00:00
Vicente J. Botet Escriba
c0bea158d4 Thread: Use of BOOST_ASSERT_MSG
[SVN r77330]
2012-03-14 06:39:07 +00:00
Vicente J. Botet Escriba
70686b4913 Thread: Comment not yet committed test
[SVN r77294]
2012-03-10 17:27:10 +00:00
Vicente J. Botet Escriba
14502dd715 Thread: Added test for upgrade_lock
[SVN r77293]
2012-03-10 17:17:14 +00:00
Vicente J. Botet Escriba
8ee986536b Thread: Added test for shared_lock move from other locks
[SVN r77292]
2012-03-10 17:07:39 +00:00
Vicente J. Botet Escriba
8ed82798d2 Thread: Fix #6673 and partial fix for 6671, 6672, 6675 which need to add the documentation and test
[SVN r77291]
2012-03-10 17:05:34 +00:00
Vicente J. Botet Escriba
ebfe10b7df Thread: Fix error on pthread/shared_mutex.hpp try_lock_xxx_for, which should use the try_lock_xxx_until+fix #6674
[SVN r77290]
2012-03-10 17:01:27 +00:00
Vicente J. Botet Escriba
4aa26180ca Thread: removed output to cout to fix 6612
[SVN r77224]
2012-03-04 20:56:42 +00:00
Vicente J. Botet Escriba
89496448d9 Thread: Update doc removing thread_move_t
[SVN r77136]
2012-02-28 18:49:22 +00:00
Vicente J. Botet Escriba
dfa0a3979a Thread: Add explicit #error when the test is not applicable
[SVN r77041]
2012-02-16 18:12:03 +00:00
Vicente J. Botet Escriba
396cd7db4f Thread: Added traces to try to catch some issues
[SVN r77038]
2012-02-16 17:40:47 +00:00
Vicente J. Botet Escriba
0351d59060 Thread: Added chrono i/f and improve move semantics for shared_mutex and shared_lock (pthread)
[SVN r77011]
2012-02-13 23:20:42 +00:00
Vicente J. Botet Escriba
6f0b0e976d Thread: uncomment Frvalue_pass test
[SVN r77004]
2012-02-13 07:48:23 +00:00
Vicente J. Botet Escriba
dd5d687014 Thread: Added chrono i/f for shared_mutex pthread
[SVN r77003]
2012-02-12 22:38:59 +00:00
Vicente J. Botet Escriba
5d8b0891bd Thread: Don't fail when native_handle is not defined
[SVN r76996]
2012-02-12 16:47:19 +00:00
Vicente J. Botet Escriba
7dc95f63d3 Thread: Move semantics cleanup
[SVN r76995]
2012-02-12 16:44:43 +00:00
Jürgen Hunold
a7adc5865b Fix: correct logic for enabling c++11 explicit conversion operators
[SVN r76959]
2012-02-09 20:21:43 +00:00
Vicente J. Botet Escriba
cdbe5766fa Thread: try to fix 6456 - trunk compilation errors converting future_errc to int
[SVN r76952]
2012-02-08 21:34:29 +00:00
Vicente J. Botet Escriba
b1cac0731c Thread: Added explicit to operator bool for locks
[SVN r76951]
2012-02-08 21:32:05 +00:00
Vicente J. Botet Escriba
fc8de511c6 Thread: Added detail/scoped_enumm.hpp file and adaptat enum classes to the new interface
[SVN r76777]
2012-01-29 18:27:26 +00:00
Vicente J. Botet Escriba
defdb8ff1c Thread: Try to fix 4885 - Access violation in set_tss_data at process exit due to invalid assumption about TlsAlloc
[SVN r76752]
2012-01-28 16:02:01 +00:00
Vicente J. Botet Escriba
9a08a8478f Thread: Try to fix 6431 - MinGW: Cannot export (anonymous namespace)::thread_binder
[SVN r76598]
2012-01-20 18:53:55 +00:00
Vicente J. Botet Escriba
a6f7a0180b Thread: Try to fix min stack size
[SVN r76597]
2012-01-20 18:52:21 +00:00
Vicente J. Botet Escriba
5a59df4476 Thread: Try to fix min stack size
[SVN r76596]
2012-01-20 18:51:24 +00:00
Vicente J. Botet Escriba
1df9d7c575 Thread: avoid the use of Boost.Chrono for vacpp toolset
[SVN r76581]
2012-01-18 21:07:13 +00:00
Vicente J. Botet Escriba
65008b11f7 Thread: Try to fix some checks that fails depending on the way the threads are switched (the time constraint is too high)
[SVN r76580]
2012-01-18 21:04:47 +00:00
Vicente J. Botet Escriba
b18314878a Thread: try to make it possible to avoid the use of Boost.Chrono
[SVN r76570]
2012-01-18 00:13:17 +00:00
Vicente J. Botet Escriba
11a951c679 Thread: Try to fix some checks that fails depending on the way the threads are switched (the time constraint is too high)
[SVN r76565]
2012-01-17 22:24:06 +00:00
Vicente J. Botet Escriba
c67e3ff7b9 Thread: try to fix #6420 - Call to forward ambiguous
[SVN r76561]
2012-01-17 18:51:36 +00:00
Vicente J. Botet Escriba
e5a633cc41 Thread: Try to fix #6418 - error: 'X(X&&)' cannot be defaulted
[SVN r76558]
2012-01-17 18:31:03 +00:00
Vicente J. Botet Escriba
3724d847cf Thread: Try to fix #6419 - Error: PTHREAD_STACK_MIN is not always defined when PTHREADS are used
[SVN r76557]
2012-01-17 18:28:46 +00:00
Vicente J. Botet Escriba
b6063b5c60 * [@http://svn.boost.org/trac/boost/ticket/2741 #2741] Proposal to manage portable and non portable thread attributes.
* [@http://svn.boost.org/trac/boost/ticket/6195 #6195] c++11 compliance: Provide the standard time related interface using Boost.Chrono. 
* [@http://svn.boost.org/trac/boost/ticket/6224 #6224] c++11 compliance: Add the use of standard noexcept on compilers supporting them. 
* [@http://svn.boost.org/trac/boost/ticket/6226 #6226] c++11 compliance: Add explicit bool conversion from locks. 
* [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11. 
* [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization.
* [@http://svn.boost.org/trac/boost/ticket/6273 #6273] c++11 compliance: Add cv_status enum class and use it on the conditions wait functions. 
* [@http://svn.boost.org/trac/boost/ticket/6194 #6194] Adapt to Boost.Move. 
 	
Fixed Bugs:

* [@http://svn.boost.org/trac/boost/ticket/2575 #2575] Bug- Boost 1.36.0 on Itanium platform.
* [@http://svn.boost.org/trac/boost/ticket/4921 #4921] BOOST_THREAD_USE_DLL and BOOST_THREAD_USE_LIB are crucial and need to be documented.
* [@http://svn.boost.org/trac/boost/ticket/5013 #5013] documentation: boost:🧵 pthreas_exit causes terminate().

* [@http://svn.boost.org/trac/boost/ticket/5351 #5351] interrupt a future get boost::unknown_exception.
* [@http://svn.boost.org/trac/boost/ticket/5516 #5516] Upgrade lock is not acquired when previous upgrade lock releases if another read lock is present. 
* [@http://svn.boost.org/trac/boost/ticket/5990 #5990] shared_future<T>::get() has wrong return type. 
* [@http://svn.boost.org/trac/boost/ticket/6174 #6174] packaged_task doesn't correctly handle moving results.



[SVN r76543]
2012-01-16 17:32:08 +00:00
Vicente J. Botet Escriba
09362f0eac Thread: merge from trunk to fix #6141, #5594, #5040 and #5502.
[SVN r76346]
2012-01-07 20:52:57 +00:00
Vicente J. Botet Escriba
32b3f3f569 Thread: Fix typo on auto_ptr
[SVN r76345]
2012-01-07 20:15:14 +00:00
Vicente J. Botet Escriba
0d08362291 Thread: Added new v2 files
[SVN r76300]
2012-01-03 22:31:11 +00:00
Vicente J. Botet Escriba
9f120a80a7 Thread: Updated Jamfiles to take care of Boost.Chrono, Boost.System and the new tests
[SVN r76298]
2012-01-03 21:50:37 +00:00
Vicente J. Botet Escriba
2eb6fd754e Thread: Added doc related to a lot of tickets mainly the time related #6195, noexcept #6224, exceptions #6230, cv_status #6273
[SVN r76297]
2012-01-03 21:45:31 +00:00
Vicente J. Botet Escriba
9f4a8973d0 Thread: Added test related to tickets
[SVN r76296]
2012-01-03 21:25:58 +00:00
Vicente J. Botet Escriba
a4d9355060 Threads: Added a lot of unit tests
[SVN r76295]
2012-01-03 21:23:11 +00:00
Vicente J. Botet Escriba
5a7545afbd Thread Towards #6273 - Add cv_status enum class and use it on the conditions wait functions
[SVN r76294]
2012-01-03 21:12:59 +00:00
Vicente J. Botet Escriba
8affa33718 Thread fixed Bugs:
* [@http://svn.boost.org/trac/boost/ticket/2309 #2309] Lack of g++ symbol visibility support in Boost.Thread. 
* [@http://svn.boost.org/trac/boost/ticket/2639 #2639] documentation should be extended(defer_lock, try_to_lock, ...).

* [@http://svn.boost.org/trac/boost/ticket/3639 #3639] Boost.Thread doesn't build with Sun-5.9 on Linux.
* [@http://svn.boost.org/trac/boost/ticket/3762 #3762] Thread can't be compiled with winscw (Codewarrior by Nokia).
* [@http://svn.boost.org/trac/boost/ticket/3885 #3885] document about mix usage of boost.thread and native thread api.
* [@http://svn.boost.org/trac/boost/ticket/3975 #3975] Incorrect precondition for promise::set_wait_callback().

* [@http://svn.boost.org/trac/boost/ticket/4048 #4048] thread::id formatting involves locale
* [@http://svn.boost.org/trac/boost/ticket/4315 #4315] gcc 4.4 Warning: inline ... declared as dllimport: attribute ignored. 
* [@http://svn.boost.org/trac/boost/ticket/4480 #4480] OpenVMS patches for compiler issues workarounds.
* [@http://svn.boost.org/trac/boost/ticket/4819 #4819] boost.thread's documentation misprints.

* [@http://svn.boost.org/trac/boost/ticket/5423 #5423] thread issues with C++0x.
* [@http://svn.boost.org/trac/boost/ticket/5617 #5617] boost::thread::id copy ctor.
* [@http://svn.boost.org/trac/boost/ticket/5739 #5739] set-but-not-used warnings with gcc-4.6.
* [@http://svn.boost.org/trac/boost/ticket/5826 #5826] threads.cpp: resource leak on threads creation failure.
* [@http://svn.boost.org/trac/boost/ticket/5839 #5839] thread.cpp: ThreadProxy leaks on exceptions.
* [@http://svn.boost.org/trac/boost/ticket/5859 #5859] win32 shared_mutex constructor leaks on exceptions. 

* [@http://svn.boost.org/trac/boost/ticket/6100 #6100] Compute hardware_concurrency() using get_nprocs() on GLIBC systems.
* [@http://svn.boost.org/trac/boost/ticket/6168 #6168] recursive_mutex is using wrong config symbol (possible typo).
* [@http://svn.boost.org/trac/boost/ticket/6175 #6175] Compile error with SunStudio.
* [@http://svn.boost.org/trac/boost/ticket/6200 #6200] patch to have condition_variable and mutex error better handle EINTR. 
* [@http://svn.boost.org/trac/boost/ticket/6207 #6207] shared_lock swap compiler error on clang 3.0 c++11. 
* [@http://svn.boost.org/trac/boost/ticket/6208 #6208] try_lock_wrapper swap compiler error on clang 3.0 c++11. 




[SVN r76291]
2012-01-03 17:31:50 +00:00
Vicente J. Botet Escriba
4d25ea1760 Thread: protect of threading=single by forcing threading=multi
[SVN r76283]
2012-01-02 22:08:02 +00:00
Vicente J. Botet Escriba
6ec8e2ccec Thread: Fix error following last commit 76277 for #6141
[SVN r76280]
2012-01-02 17:48:18 +00:00
Vicente J. Botet Escriba
97d0ae6527 Thread: #6141 - Compilation error when boost.thread and boost.move are used together
[SVN r76277]
2012-01-02 17:12:01 +00:00
Vicente J. Botet Escriba
50a74d0eda Thread: Try to solve #6341 Boost.Thread defines boost::move which conflicts with Boost.Move
[SVN r76268]
2012-01-02 00:33:32 +00:00
Vicente J. Botet Escriba
f9e03b5eaa Thread: Notify shread_cond when state.exclusive_waiting_blocked=false in shared_mutex::timed_lock to resolve #5502
[SVN r76084]
2011-12-20 21:13:22 +00:00
Vicente J. Botet Escriba
ad571bd898 Thread: Fix error returning in constructor
[SVN r76078]
2011-12-20 12:42:45 +00:00
Vicente J. Botet Escriba
de8ef9aee4 Thread: reverse part of commit r76040 which breaks msvc-10.0
[SVN r76075]
2011-12-19 23:50:03 +00:00
Vicente J. Botet Escriba
21f75da2f6 Thread: don't overload move when BOOST_NO_RVALUE_REFERENCES is not defined
[SVN r76074]
2011-12-19 23:22:08 +00:00
Vicente J. Botet Escriba
233dbf8075 Thread: dont use thread_move_t when BOOST_NO_RVALUE_REFERENCES is not defined
[SVN r76073]
2011-12-19 23:20:31 +00:00
Vicente J. Botet Escriba
d8f1ba9b3d Thread: added move definition when BOOST_NO_RVALUE_REFERENCES is not defined
[SVN r76040]
2011-12-18 14:34:09 +00:00
Vicente J. Botet Escriba
1241f18215 Thread: replace BOOST_HAS_RVALUE_REFS by BOOST_NO_RVALUE_REFERENCES and protect uses of thread_move_t
[SVN r76039]
2011-12-18 14:31:36 +00:00
Vicente J. Botet Escriba
b6604882eb Thread: Added BOOST_THREAD_VERSION so that we can add backward incompatible features
[SVN r76037]
2011-12-18 13:37:37 +00:00
Vicente J. Botet Escriba
a9c9d5c499 Thread: #4048 thread::id formatting: use ios_flags_saver
[SVN r76011]
2011-12-17 09:02:10 +00:00
Vicente J. Botet Escriba
9a827d937e Thread: #4921 BOOST_THREAD_USE_DLL and BOOST_THREAD_USE_LIB are crucial and need to be documented
[SVN r75905]
2011-12-11 18:16:07 +00:00
Vicente J. Botet Escriba
38594f889a Thread: #5013 - documentation: boost:🧵 pthreas_exit causes terminate()
[SVN r75904]
2011-12-11 18:12:55 +00:00
Vicente J. Botet Escriba
04c17e45b3 Thread: #5594 boost::shared_mutex not fully compatible with Windows CE.
[SVN r75903]
2011-12-11 15:43:13 +00:00
Vicente J. Botet Escriba
730a8de024 Thread: #5040 future.hpp in boost::thread does not compile with /clr
[SVN r75901]
2011-12-11 13:32:41 +00:00
Vicente J. Botet Escriba
7eac2fe3e4 Thread: Fix auto_ptr error
[SVN r75886]
2011-12-10 14:59:43 +00:00
Vicente J. Botet Escriba
267243d959 Thread: Fix typo
[SVN r75885]
2011-12-10 14:51:16 +00:00
Vicente J. Botet Escriba
f587262c8e Thread: Added compliance matrix
[SVN r75884]
2011-12-10 11:56:45 +00:00
Vicente J. Botet Escriba
ebf458dbd0 Thread: update fixed tickets for 1.49
[SVN r75883]
2011-12-10 11:54:36 +00:00
Vicente J. Botet Escriba
f64b5559dd Thread: #6200-mutex error better handle EINTR
[SVN r75882]
2011-12-10 10:55:53 +00:00
Vicente J. Botet Escriba
2ddcd5f678 Thread: #6200-mutex error better handle EINTR
[SVN r75860]
2011-12-07 23:15:20 +00:00
Vicente J. Botet Escriba
cac715937a Thread: boost thread unit test module bug on Microsoft Visual Studio debug mode
[SVN r75858]
2011-12-07 21:08:52 +00:00
Vicente J. Botet Escriba
39f43feb11 Thread: Added more fixed tickets
[SVN r75807]
2011-12-05 00:27:46 +00:00
Vicente J. Botet Escriba
58d65b17ea Thread: #5859 win32 shared_mutex constructor leaks on exceptions
[SVN r75806]
2011-12-04 23:06:24 +00:00
Vicente J. Botet Escriba
4314f0cac3 Thread: #3762 Thread can't be compiled with winscw (Codewarrior by Nokia) (win part)
[SVN r75802]
2011-12-04 15:18:32 +00:00
Vicente J. Botet Escriba
d4da369930 Thread: 6207/6208 shared_lock/try_lock_wrapper swap compiler error on clang 3.0 c++11
[SVN r75801]
2011-12-04 14:58:08 +00:00
Vicente J. Botet Escriba
6f1876b618 Thread: #6100 Compute hardware_concurrency() using get_nprocs() on GLIBC systems
[SVN r75800]
2011-12-04 14:33:08 +00:00
Vicente J. Botet Escriba
c6e872ceb0 Thread: #2309 - Lack of g++ symbol visibility support in Boost.Thread
[SVN r75799]
2011-12-04 10:36:34 +00:00
Vicente J. Botet Escriba
72d809819f Thread: #3639 Boost.Thread doesn't build with Sun-5.9 on Linux
[SVN r75798]
2011-12-04 09:35:34 +00:00
Vicente J. Botet Escriba
dd09ef3362 Thread: 4315 gcc 4.4 Warning: inline ... declared as dllimport: attribute ignored
[SVN r75791]
2011-12-03 17:56:38 +00:00
Vicente J. Botet Escriba
aa7941fae2 Thread: 2639 documentation should be extended(defer_lock, try_to_lock, ...) + 3885 document about mix usage of boost.thread and native thread api. + 3975 Incorrect precondition for promise::set_wait_callback() + 4819 boost.thread's documentation misprints.
[SVN r75790]
2011-12-03 14:28:17 +00:00
Vicente J. Botet Escriba
35af4a8f35 Thread: 3762 Thread can't be compiled with winscw (Codewarrior by Nokia) (pthread part)
[SVN r75789]
2011-12-03 14:11:02 +00:00
Vicente J. Botet Escriba
a01fd3dd76 Thread: 4480 (move part) + 6175 Compile error with SunStudio
[SVN r75788]
2011-12-03 14:06:32 +00:00
Vicente J. Botet Escriba
d220da89d1 Thread: 4480 OpenVMS patches for compiler issues workarounds (only sleep part)
[SVN r75787]
2011-12-03 13:57:06 +00:00
Vicente J. Botet Escriba
55c75e9299 Thread: 5423 thread issues with C++0x
[SVN r75786]
2011-12-03 13:50:40 +00:00
Vicente J. Botet Escriba
616ea87a0a Thread: 5739 set-but-not-used warnings with gcc-4.6
[SVN r75785]
2011-12-03 13:25:55 +00:00
Vicente J. Botet Escriba
319ba2fe75 Thread: 6200 patch to have condition_variable and mutex error better handle EINTR
[SVN r75781]
2011-12-03 10:09:11 +00:00
Vicente J. Botet Escriba
d79eeff779 Thread:6168 recursive_mutex is using wrong config symbol (possible typo)
[SVN r75780]
2011-12-03 10:02:37 +00:00
Gennadiy Rozental
26d38748db eliminated test_case_template.hpp
[SVN r74735]
2011-10-05 10:28:08 +00:00
Gennadiy Rozental
5c124234bb eliminated unit_test_framework and BOOST_MESSAGE
[SVN r74731]
2011-10-05 09:52:10 +00:00
Anthony Williams
b991c9a8a0 Merged thread changes from trunk
[SVN r72431]
2011-06-06 08:28:31 +00:00
Anthony Williams
681af396b8 Change pin_to_zero and interruptible_wait to use (u)intmax_t rather than (unsigned) long, to avoid warnings about truncation
[SVN r72303]
2011-05-31 12:28:11 +00:00
Anthony Williams
cac0eaa6c3 Put static functions inside extern "C" block rather than trying to declare each as extern "C"
[SVN r72176]
2011-05-26 09:00:58 +00:00
Anthony Williams
a64fa2c18f extern "C" functions are static
[SVN r72166]
2011-05-25 21:18:59 +00:00
Neil Groves
f07640850b [boost][thread] - Resolved Ticket 5170 by making the extern "C" functions static.
[SVN r72120]
2011-05-23 13:24:16 +00:00
Marshall Clow
ab665c8c56 Merge fixes to release; Fixes #1988
[SVN r71676]
2011-05-02 20:56:53 +00:00
Marshall Clow
e43586ffac Renamed BOOST_NO_THREADEX -> BOOST_HAS_THREADEX and BOOST_NO_GETSYSTEMTIMEASFILETIME --> BOOST_HAS_GETSYSTEMTIMEASFILETIME - Refs #1988
[SVN r71533]
2011-04-27 15:51:07 +00:00
Anthony Williams
9cc243837d Fixed typo
[SVN r70470]
2011-03-23 08:17:45 +00:00
Anthony Williams
de7e3baabc Applied patch from issue #4849
[SVN r70383]
2011-03-21 23:09:07 +00:00
Anthony Williams
7ec9804540 Merged Boost.Thread changes from trunk
[SVN r70382]
2011-03-21 22:59:40 +00:00
Anthony Williams
5e29afcb57 Remove inner definition of cond_res from timed_wait so outer variable
is set correctly


[SVN r69621]
2011-03-07 08:39:37 +00:00
Anthony Williams
0a1085d9be Patch condition variables to ensure that the cond mutex is unlocked before we try and check for interruption
[SVN r69547]
2011-03-04 15:44:53 +00:00
David Deakins
0439d53704 Minor patch to fix support for Windows CE (use 0xFFFFFFFF in place of TLS_OUT_OF_INDEXES on Windows CE since Windows CE does not define this constant).
[SVN r69115]
2011-02-21 04:07:13 +00:00
Hartmut Kaiser
7c9116af2e Spirit: merge from trunk
[SVN r68078]
2011-01-13 02:11:19 +00:00
Hartmut Kaiser
5ac2ff4521 Reverted accidental commit, sorry...
[SVN r67895]
2011-01-09 22:21:03 +00:00
Hartmut Kaiser
8565a3e472 Spirit: replaced proto::lit with spirit::lit
[SVN r67754]
2011-01-07 17:50:06 +00:00
Anthony Williams
3648bc8cb0 Throw condition_error if pthread_cond_wait fails, rather than asserting
[SVN r67734]
2011-01-06 22:49:41 +00:00
Anthony Williams
73121eda9d Better fix for #4736 --- ensure we have tried to allocate TLS value
before complaining that it's not there, especially in native threads


[SVN r66518]
2010-11-12 09:11:22 +00:00
Anthony Williams
768e92b0e9 Added comment about lack of cleanup on native threads on some platforms
[SVN r66480]
2010-11-10 10:02:42 +00:00
Anthony Williams
98333b7dcf fix for issue #4736 --- avoid setting tls data after the key has been destroyed
[SVN r66471]
2010-11-09 12:54:23 +00:00
Anthony Williams
4e0007780c Fix for issue #2330 - remove race condition in condition_variable::wait wrt interruption checking
[SVN r66228]
2010-10-28 14:18:00 +00:00
Anthony Williams
10f0c3e08e Fix for issue #4531 --- promise::lazy_init uses shared_ptr atomic access functions to avoid race
[SVN r66146]
2010-10-22 14:01:12 +00:00
Anthony Williams
fa2950a04b Fix for #4650 --- put tss_cleanup_implemented in the boost namespace
[SVN r66142]
2010-10-22 09:58:33 +00:00
Anthony Williams
ebfb62ca49 Fixed issue #4727 --- only use microsec clock if available
[SVN r66141]
2010-10-22 09:26:15 +00:00
Anthony Williams
96023e81af Fix for issue #4258 --- static linking now works with recent versions of the mingw runtime
[SVN r66140]
2010-10-22 08:57:19 +00:00
Andrey Semashev
9c07d0ff5d Fixed compilation with MSVC and, probably, other compilers.
[SVN r64996]
2010-08-25 15:25:16 +00:00
Anthony Williams
72a85b396c Fix for issue #4368 --- ensure mutex is destroyed if setattr call fails
[SVN r63799]
2010-07-09 22:00:51 +00:00
Anthony Williams
87786091bb Tidied up call_once to remove unused throw_count stuff
[SVN r63796]
2010-07-09 21:21:48 +00:00
Anthony Williams
784494274b Fix for issue #4225 to allow static initialization of boost::once_flag
[SVN r63795]
2010-07-09 21:15:57 +00:00
Anthony Williams
68012dd92c Fix for issue #4413 --- allow wait_for_any to work with empty ranges
[SVN r63790]
2010-07-09 19:18:16 +00:00
Anthony Williams
e40be775fe Ensure futures and shared_mutex work on MSVC-10; fix for issue #2501
[SVN r63750]
2010-07-08 15:25:45 +00:00
Anthony Williams
64e6924132 Moved the test for _GNU_SOURCE to last to try and fix issue #4395
[SVN r63701]
2010-07-06 15:12:21 +00:00
Anthony Williams
4bbf47086d Added missing "typename"
[SVN r63651]
2010-07-05 14:37:13 +00:00
Anthony Williams
7c674bc255 Added overload for swap member function that takes an lvalue reference
in all cases


[SVN r63650]
2010-07-05 14:35:45 +00:00
Steven Watanabe
6b9a2d791b Protect get_thread_info from macro expansion to prevent errors on Haiku. Fixes #4341.
[SVN r63295]
2010-06-24 19:38:16 +00:00
Steven Watanabe
4551e8759b Use __SUNPRO_CC instead of SUNPRO_CC. Fixes #4363.
[SVN r63216]
2010-06-22 01:59:23 +00:00
Daniel James
9442976bdb Update various libraries' documentation build.
Mostly to use the images and css files under doc/src instead of
doc/html, usually be deleting the settings in order to use the defaults.
Also add 'boost.root' to some builds in order to fix links which rely on
it.

[SVN r63146]
2010-06-20 18:00:48 +00:00
Steven Watanabe
8d07df176f Fix non-friend stream operator of thread::id
[SVN r62804]
2010-06-11 14:49:07 +00:00
Steven Watanabe
4b22aff33e Add old auto-link macro for backwards compatibility.
[SVN r62802]
2010-06-11 14:38:28 +00:00
Anthony Williams
93dee254d0 Don't use windows threads if BOOST_DISABLE_WIN32 defined. Fix for
issue #3760


[SVN r62723]
2010-06-10 08:43:10 +00:00
Anthony Williams
a29b598205 Fix for issue #3761 --- if define operator<< for thread::id outside
the class if not supported inside.


[SVN r62722]
2010-06-10 08:34:52 +00:00
Anthony Williams
e3b20eaae9 Remove warnings. Fix for issue #3611
[SVN r62721]
2010-06-10 08:22:39 +00:00
Anthony Williams
d369fb0f94 Emulate recursive mutex if pthread_mutexattr_settype not
available. Fix for issue #2955


[SVN r62720]
2010-06-10 08:10:26 +00:00
Anthony Williams
d816bca42f Only apply Sunpro workarounds for older compilers. Fix for issue #4071
[SVN r62719]
2010-06-10 07:43:17 +00:00
Anthony Williams
d6bb11c4e9 Added __cdecl to PVAPI. Fix for issue #1470
[SVN r62718]
2010-06-10 07:40:12 +00:00
Anthony Williams
2fdcefac05 Added static cast in move of upgrade_lock to work with MSVC10 and g++4.5
[SVN r62717]
2010-06-10 07:38:23 +00:00
Anthony Williams
044c3cc11e Explicitly cast to rvalue reference in cast_to_rval so it works with
MSVC10 and g++4.5


[SVN r62715]
2010-06-10 07:36:57 +00:00
Anthony Williams
bd9223b525 Don't warn about long long usage with gcc. Fix for issue #3680
[SVN r62654]
2010-06-09 13:04:06 +00:00
Anthony Williams
347703dab2 Changed while(true) to for(;;) to avoid warnings. Fix for issue #3195
[SVN r62652]
2010-06-09 12:36:11 +00:00
Anthony Williams
f9a0e450e1 Removed thread_info_mutex as unnecessary and cause of potentially-throwing destructor. Fix for issue #3097
[SVN r62650]
2010-06-09 11:35:41 +00:00
Anthony Williams
f6b8cdd1f5 Use BOOST_THREAD_DYN_LINK instead of BOOST_THREAD_DYN_DLL for
compatibility with the rest of boost. Fix for issue #2874


[SVN r62643]
2010-06-09 08:55:09 +00:00
Anthony Williams
6727013302 Use time_duration::tick_type rather than long when calculating due
time to fix issue #4318


[SVN r62642]
2010-06-09 08:19:47 +00:00
Anthony Williams
cda12a2660 Added BOOST_THREAD_DECL to friend declaration of
this_thread::get_id. Fix for issue #4316


[SVN r62641]
2010-06-09 07:59:31 +00:00
Anthony Williams
c3c2072472 Added unimplemented default constructor to derived to avoid complaints
about the constructors of T in some compilers. Fix for issue #4317


[SVN r62639]
2010-06-09 07:52:25 +00:00
Anthony Williams
bfc226fdc0 Add extra braces to fix issue #4321
[SVN r62638]
2010-06-09 07:46:29 +00:00
Anthony Williams
fd28e1a7fb Added missing #includes. Fix for issue #4322
[SVN r62637]
2010-06-09 07:40:09 +00:00
Anthony Williams
b11911f5e5 Moved thread startup and shutdown hooks to namespace boost
[SVN r62636]
2010-06-09 07:37:44 +00:00
Anthony Williams
a1587d070f Replace use of noncopyable with private copy operations, issue #3244
[SVN r62633]
2010-06-09 06:58:35 +00:00
Anthony Williams
df2f43bc61 Added documentation for this_thread::sleep overload that takes a
system_time. see issue #3179


[SVN r62632]
2010-06-09 06:48:37 +00:00
Anthony Williams
895e8eea52 Added "inline" on system_time overload of timed_wait to fix issue #2747
[SVN r62631]
2010-06-09 06:42:57 +00:00
Anthony Williams
97d6249f3b Added patch from issue #4305 --- limit SunCC workarounds to older versions
[SVN r62601]
2010-06-08 21:39:56 +00:00
Anthony Williams
7a8ed98eb5 Removed commented out code
[SVN r62564]
2010-06-08 13:06:58 +00:00
Anthony Williams
d611eece19 Updated tests for mutex members to handle range-based lock() and try_lock(), and fix issue #2704
[SVN r62562]
2010-06-08 12:06:03 +00:00
Anthony Williams
a99320f5a4 Updated get_due_time to handle the case where a "tick" is less than
100ns, trac issue #2447


[SVN r62555]
2010-06-08 08:40:46 +00:00
Anthony Williams
c97484943a Check limits when attempting to lock shared_mutex --- trac issue #2293
[SVN r62553]
2010-06-08 07:28:53 +00:00
Anthony Williams
547d9bd844 Fix for issue #868 --- provide element_type typedef
[SVN r62552]
2010-06-08 07:11:28 +00:00
Anthony Williams
1a65aab05a Applied patch from ticket 2918
[SVN r62505]
2010-06-07 09:08:09 +00:00
Anthony Williams
2e869aeb86 Added documentation for thread move assignment
[SVN r62504]
2010-06-07 09:04:54 +00:00
Anthony Williams
d729776575 Added documentation of thread move constructor
[SVN r62503]
2010-06-07 08:59:27 +00:00
Anthony Williams
895c436405 Fix for issue #4238: timed_lock_upgrade should not call timed_lock
[SVN r62502]
2010-06-07 08:43:15 +00:00
Anthony Williams
4ae2932792 Fix copy constructor and copy-assignment operator for condition_variable_any
[SVN r62501]
2010-06-07 08:28:42 +00:00
Anthony Williams
a52be2bdbb Consistently use count_type rather than unsigned for indexes into
future waiters vector


[SVN r62500]
2010-06-07 08:25:43 +00:00
Anthony Williams
31c4792216 Added missing inline
[SVN r62229]
2010-05-26 06:48:58 +00:00
Anthony Williams
39fd9c0b47 Fix for trac issue #3269
[SVN r62123]
2010-05-21 17:14:23 +00:00
Anthony Williams
9c25df3402 Sleeping for a negative time is same as sleeping for 0ms, fix for
issue #3178


[SVN r62122]
2010-05-21 16:59:56 +00:00
Anthony Williams
fb150b5038 Added support for BOOST_NO_IOSTREAM
[SVN r62119]
2010-05-21 15:19:06 +00:00
Anthony Williams
8cff3a167e Added documentation for boost::move on thread objects
[SVN r62079]
2010-05-18 08:25:02 +00:00
Anthony Williams
2be1431f60 Test for __APPLE__ before _GNU_SOURCE so we can compile on Intel/Darwin
[SVN r62053]
2010-05-17 08:22:14 +00:00
Anthony Williams
255b7ed7f6 Fix for compile error win Sun CC 5.9
[SVN r61618]
2010-04-27 13:23:00 +00:00
Anthony Williams
58fd27399e Added patch to fix issue #2501
[SVN r61429]
2010-04-20 15:02:47 +00:00
Anthony Williams
5f88ba1e47 Fix use of rvalue ref in futures
[SVN r60990]
2010-04-01 12:56:44 +00:00
Anthony Williams
ab569461d8 Modified boost::thread to work with MSVC10 RC
[SVN r59856]
2010-02-23 13:46:13 +00:00
Anthony Williams
7093fc670b Disable templated rvalue ref constructor for MSVC10
[SVN r59758]
2010-02-19 09:54:00 +00:00
Anthony Williams
6f2b030253 Fixes to some uses of rvalue references; patch to avoid var size warnings on 64-bit platforms in future.hpp
[SVN r59752]
2010-02-18 21:54:46 +00:00
Anthony Williams
0e61e679af Overload boost::move for thread& and thread&&
[SVN r59727]
2010-02-17 08:34:09 +00:00
Anthony Williams
b40998e1b5 Changed boost.thread to use BOOST_NO_RVALUE_REFERENCES rather than BOOST_HAS_RVALUE_REFS
[SVN r59699]
2010-02-16 14:57:30 +00:00
Anthony Williams
174d701bc3 Using BOOST_ASSERT rather than assert
[SVN r57940]
2009-11-26 09:35:31 +00:00
Anthony Williams
f2143d08b9 Added missing BOOST_THREAD_DECL for at_thread_exit_function
[SVN r57937]
2009-11-26 08:13:44 +00:00
Anthony Williams
1273e2620d Don't use timed_lock to do a lock
[SVN r57936]
2009-11-26 08:13:01 +00:00
Anthony Williams
c719f6e37e Added test and fix for issue 2742
[SVN r57925]
2009-11-25 11:05:55 +00:00
Anthony Williams
37922d8ce0 Added a wait call to new call_once
[SVN r57924]
2009-11-25 09:42:29 +00:00
Anthony Williams
7b79a31f40 A partial fix for issue #2100: use boost::throw_exception for all exceptions except thread_interrupted
[SVN r57912]
2009-11-24 21:49:27 +00:00
Anthony Williams
9a09406f77 Ensure call_once event is correctly cleaned up
[SVN r57889]
2009-11-24 11:52:09 +00:00
Anthony Williams
9bdb778478 Only allocate an event if there is contention in call_once
[SVN r57882]
2009-11-24 09:59:21 +00:00
Anthony Williams
9621dafe46 Clarify note on call_once
[SVN r57862]
2009-11-23 11:31:08 +00:00
Anthony Williams
d7c9837844 Added a note highlighting that recursive use of call_once will cause deadlock.
[SVN r57861]
2009-11-23 11:24:53 +00:00
Anthony Williams
27bb7803ae Update docs for at_thread_exit
[SVN r57380]
2009-11-04 21:38:45 +00:00
Anthony Williams
c0e1086f2c More fixes for compilers with rvalue ref support
[SVN r57173]
2009-10-27 13:22:08 +00:00
Anthony Williams
ffa751c617 Fix for move assignment of unique_lock if rvalue refs supported
[SVN r57171]
2009-10-27 10:40:57 +00:00
Anthony Williams
b8ad60a2d6 Fix for bug #2067 --- use shared_mutex for thread_group rather than a simple mutex
[SVN r57169]
2009-10-27 09:45:53 +00:00
Anthony Williams
5db0aac816 Added futures to boost.thread
[SVN r57064]
2009-10-22 09:33:21 +00:00
Troy D. Straszheim
3fae7c5184 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
Anthony Williams
47889a8f22 boost.thread exception types are now header-only so some uses of boost.thread can be header only
[SVN r56019]
2009-09-04 19:55:31 +00:00
Troy D. Straszheim
8d22c3869b Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
Vladimir Prus
235ed4afe0 Check _GNU_SOURCE before using get_nprocs.
The latter function is not POSIX, but a GNU extension and therefore
not available universally.


[SVN r54408]
2009-06-27 09:22:41 +00:00
Anthony Williams
627cb7f774 Fixed typo
[SVN r53412]
2009-05-29 20:48:07 +00:00
Anthony Williams
09021af350 Changed thread_specific_ptr to use a map for faster lookup, and erase empty nodes
[SVN r53389]
2009-05-29 11:34:25 +00:00
Anthony Williams
31c280d1fa TSS cleanup not called for NULL data
[SVN r53388]
2009-05-29 11:05:01 +00:00
Anthony Williams
629f344f34 Test and fix for first part of issue #2797
[SVN r53387]
2009-05-29 10:57:39 +00:00
Anthony Williams
db5f924e24 Remove commented-out thread_group code
[SVN r53386]
2009-05-29 10:45:06 +00:00
Anthony Williams
9be3eb282a Attempts to improve the boost::thread move semantics; separated tests to give clearer ID; incorporated patch to fix issue #2062
[SVN r53385]
2009-05-29 09:57:15 +00:00
John Maddock
effd891a16 Remove options that are no longer required and get the PDF docs building.
[SVN r51142]
2009-02-09 16:26:26 +00:00
Anthony Williams
13db35cbf5 Undo commit from r49977 which added extraneous throw to thread example
[SVN r49978]
2008-11-28 11:01:21 +00:00
Anthony Williams
0f2d480e3c Added test for making std::thread work with std::vector
[SVN r49977]
2008-11-28 10:57:12 +00:00
Anthony Williams
9edc61e37b Removed controversial catch(...) clauses from thread class
[SVN r49969]
2008-11-27 21:15:37 +00:00
Michael A. Jackson
f4dab6aac5 Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
Michael A. Jackson
9e0550d140 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
Anthony Williams
0d1701c509 Enhanced thread move tests
[SVN r49124]
2008-10-03 07:02:57 +00:00
Anthony Williams
f2f62f93ea Test and fix for trac issue #2380: return boost::move(some_thread) now works
[SVN r49112]
2008-10-02 16:39:03 +00:00
Anthony Williams
8a329f66fb Renamed lock variables to lk to avoid name shadow warnings
[SVN r49013]
2008-09-29 16:32:24 +00:00
Anthony Williams
05d4c52918 fixed check on return code from pthread_mutex_timedlock
[SVN r48997]
2008-09-29 09:04:13 +00:00
Anthony Williams
8fd0dd0cc0 Define a raw DLL main which is called by the C runtime if we're statically linked into a DLL --- fix for issue #2199
[SVN r48537]
2008-09-02 16:56:57 +00:00
Anthony Williams
8eea5811ba Don't allocate TLS Key unless we need it; deallocate it on process exit --- partial fix for bug #2199
[SVN r48536]
2008-09-02 16:54:56 +00:00
Anthony Williams
a154c2adab Removed locked and get_active_count
[SVN r48531]
2008-09-02 10:38:17 +00:00
Anthony Williams
10bf4ed576 Removed locked and get_active_count
[SVN r48530]
2008-09-02 10:38:04 +00:00
Anthony Williams
60d12dd395 Added recursive_mutex/condition::wait() change to list of breaking changes
[SVN r48528]
2008-09-02 10:22:06 +00:00
Anthony Williams
b4e9be3c52 Added missing relative time constructor to unique_lock
[SVN r48213]
2008-08-19 10:26:53 +00:00
Anthony Williams
dcebae6d4a Renamed internal bind stuff to invoker, as more expressive
[SVN r48209]
2008-08-19 07:03:22 +00:00
Anthony Williams
0d776bcd26 Updated changes list
[SVN r48037]
2008-08-08 20:37:30 +00:00
Anthony Williams
2d6ed47cf2 Updated signature of create_thread
[SVN r48036]
2008-08-08 20:21:29 +00:00
Anthony Williams
ea06434425 Doc updates missed by previous checkin
[SVN r47826]
2008-07-26 08:37:55 +00:00
Anthony Williams
6508eff95e Added note about max number of arguments
[SVN r47818]
2008-07-25 22:22:58 +00:00
Anthony Williams
69930684a9 Added a description for the new thread constructors that allow functions with arguments.
[SVN r47817]
2008-07-25 22:21:05 +00:00
Anthony Williams
b1931a3eda Fix for trac issue #2118
[SVN r47816]
2008-07-25 22:01:04 +00:00
Anthony Williams
63b44d4e32 Added documentation for the lock and try_lock free functions
[SVN r47815]
2008-07-25 21:57:33 +00:00
Anthony Williams
f7cb8d8141 Added a description for the scoped_try_lock typedefs
[SVN r47814]
2008-07-25 21:30:37 +00:00
Anthony Williams
48c857e02c Fix for issue #2105: specify which header to include for each class or function
[SVN r47810]
2008-07-25 21:12:29 +00:00
Anthony Williams
442dc58e0f Use sysconf(_SC_NPROCESSORS_ONLN) where it is available, as a fallback
[SVN r47654]
2008-07-21 10:39:50 +00:00
Anthony Williams
25460c652c Use sysconf to detect number of processors on AIX too
[SVN r47653]
2008-07-21 10:25:08 +00:00
Anthony Williams
31a98f0a1e BOOST_NO_SFINAE isn't enough to identify compilers that can't auto-detect mutexes, so create a new macro for that, and add IBM and Sun compilers to list
[SVN r47652]
2008-07-21 10:04:26 +00:00
Anthony Williams
36c44b6f45 Borland-specific fixes should apply to all compilers for which enable_if is broken: check for BOOST_NO_SFINAE instead
[SVN r47554]
2008-07-18 13:42:10 +00:00
Anthony Williams
27426b18d1 Split lock and try_lock into mutex and range overloads without using enable_if, so it works on Borland compilers
[SVN r47472]
2008-07-16 14:41:09 +00:00
Anthony Williams
3ea9ce1c8c Fixes to make basic thread functionality work with Borland compilers again
[SVN r47471]
2008-07-16 13:19:43 +00:00
Anthony Williams
4dfc636c84 test and fix for issue #2080
[SVN r47199]
2008-07-07 22:19:28 +00:00
Anthony Williams
5fe4312c6c test and fix for issue #2081
[SVN r47197]
2008-07-07 22:04:10 +00:00
Anthony Williams
63e675a6bb Corrected description to avoid reference to arguments
[SVN r47172]
2008-07-07 07:30:27 +00:00
Anthony Williams
e92aeac7d7 Added notify functions to class synopsis
[SVN r47171]
2008-07-07 07:28:32 +00:00
Anthony Williams
f1f7eac1f2 Backwards compatibility with xtime --- test and fix for issue #2052
[SVN r47149]
2008-07-06 21:58:11 +00:00
Anthony Williams
eff0c84553 Test and fix for issue #2076
[SVN r47120]
2008-07-05 21:55:36 +00:00
Anthony Williams
58c8ce61c7 Fix for issue #2065
[SVN r47077]
2008-07-04 15:45:52 +00:00
Anthony Williams
6ac5e6953a Qualify everything with boost:: to try and avoid name clashes on AIX
[SVN r47070]
2008-07-04 07:30:35 +00:00
Anthony Williams
5d9ad59af2 Use rvalue refs for move semantics of unique_lock where available
[SVN r47033]
2008-07-03 09:16:49 +00:00
Anthony Williams
3c48a05437 Added try_lock_upgrade to shared_mutex: second half of #1867 fix
[SVN r46961]
2008-07-01 16:28:06 +00:00
Anthony Williams
4462124ff2 Added try_lock_upgrade to shared_mutex: second half of #1867 fix
[SVN r46960]
2008-07-01 16:27:59 +00:00
Anthony Williams
373f557ef7 Reduced thread counts to make tests run faster
[SVN r46958]
2008-07-01 16:22:47 +00:00
Anthony Williams
495e561398 Partial fix for issue #1867 - ensure boost::shared_mutex supports try_lock
[SVN r46956]
2008-07-01 16:04:51 +00:00
Anthony Williams
d24a579033 Partial fix for issue #1867 - ensure boost::shared_mutex supports try_lock
[SVN r46955]
2008-07-01 16:04:43 +00:00
Anthony Williams
77130424b4 Removed tabs from source files
[SVN r46706]
2008-06-26 06:43:30 +00:00
Anthony Williams
eb30688937 Added license and copyright to docs
[SVN r46705]
2008-06-26 06:41:00 +00:00
Anthony Williams
880bac0633 Added missing include of detail/config.hpp
[SVN r46624]
2008-06-23 12:14:58 +00:00
Anthony Williams
851d6a987f Correctly remove the reference type when copying the thread function into the thread data area so we don't end up with a dangling reference
[SVN r46295]
2008-06-10 15:29:35 +00:00
Anthony Williams
9bebd7b35f Disable general templated thread constructor for movable types, in order to prevent it trying to act as a thread copy constructor for EDG based compilers
[SVN r46273]
2008-06-09 14:00:03 +00:00
Anthony Williams
309acb9597 Don't try and use _interlockedbittestandset primitives if we don't know they're present
[SVN r46219]
2008-06-07 20:54:19 +00:00
Anthony Williams
a56887167e Added swap for try_lock_wrapper
[SVN r46164]
2008-06-05 12:25:58 +00:00
Anthony Williams
e984dff4e4 Combined TSS header for pthread and win32, #1958 now fixed for pthread too
[SVN r46162]
2008-06-05 11:19:06 +00:00
Anthony Williams
685e4d446b Test and fix for bug #1958 on Win32
[SVN r46161]
2008-06-05 11:16:05 +00:00
Anthony Williams
8af680f307 Added swap for unique_lock
[SVN r46160]
2008-06-05 10:39:08 +00:00
Anthony Williams
6c60cce60d Removed partial initializer for res: both values will be assigned later, so no need to initialize either
[SVN r46124]
2008-06-04 16:05:29 +00:00
Anthony Williams
5882a675bb Added extra initializer to timeout to try and eliminate warnings with some compilers
[SVN r46123]
2008-06-04 16:03:51 +00:00
Anthony Williams
a5e95845b3 Added documentation for swap()
[SVN r46122]
2008-06-04 16:00:13 +00:00
Anthony Williams
5b83d81e40 Added free function swap() for threads
[SVN r46121]
2008-06-04 15:50:34 +00:00
Anthony Williams
c8e5ad564d basic_condition_variable::lock_entry extracted to basic_cv_lock_entry in order to try and eliminate problems on Borland compiler
[SVN r46094]
2008-06-03 20:56:39 +00:00
Anthony Williams
5edfa273ff removed unused header
[SVN r46093]
2008-06-03 20:55:40 +00:00
Anthony Williams
4db57bcb10 Move thread_data to detail namespace rather than have it as a nested type of boost::thread, to try and help compilers that have problems with the partial specializations for reference_wrapper
[SVN r45912]
2008-05-29 15:38:08 +00:00
Anthony Williams
3f13340903 Don't construct function objects directly in boost::thread constructor as some compilers can't handle that.
[SVN r45911]
2008-05-29 15:36:52 +00:00
Anthony Williams
6abb53c9d3 Move definition of constructor and destructor of condition_variable into condition_variable_fwd.hpp, so they are always available
[SVN r45909]
2008-05-29 15:16:55 +00:00
Anthony Williams
fdd20a519e Use wrapper functions in try_lock_wrapper rather than using declarations, as the latter confuse some compilers
[SVN r45908]
2008-05-29 15:16:04 +00:00
Anthony Williams
67cc49f333 More tests for generic locks, and a new range version
[SVN r45897]
2008-05-29 09:02:05 +00:00
Anthony Williams
31a34cd0b5 Added missing "no"
[SVN r45870]
2008-05-28 14:50:25 +00:00
Anthony Williams
ef8c08ba99 Removed surplus "the"
[SVN r45869]
2008-05-28 12:55:30 +00:00
Anthony Williams
2991ca6c6f Added abi prefix and suffix headers
[SVN r45865]
2008-05-28 11:02:06 +00:00
Anthony Williams
52bace18b2 hardware_concurrency works for CYGWIN
[SVN r45860]
2008-05-28 09:38:14 +00:00
Anthony Williams
767d14ae4f Added documentation for time support in the thread library
[SVN r45859]
2008-05-28 09:00:32 +00:00
Anthony Williams
1a5c911e36 Added documentation for time support in the thread library
[SVN r45858]
2008-05-28 09:00:23 +00:00
Anthony Williams
6e42a04e43 Added note about move support
[SVN r45856]
2008-05-28 08:09:07 +00:00
Anthony Williams
28be2cfeef intrusive_ptr_add_ref and intrusive_ptr_release need to be inline if defined in the header
[SVN r45809]
2008-05-27 06:32:05 +00:00
Anthony Williams
8be168fd87 Basic tests for lock() when other thread is acquiring locks in same or opposite order
[SVN r45767]
2008-05-26 08:59:48 +00:00
Anthony Williams
eee95fef57 Initial test for generic lock functions
[SVN r45766]
2008-05-26 08:40:21 +00:00
Anthony Williams
9ea179b052 Initial test for generic lock functions
[SVN r45765]
2008-05-26 08:40:13 +00:00
Anthony Williams
6868280409 Try and avoid compile errors in test_thread_callable_object_one_argument
[SVN r45764]
2008-05-26 07:36:16 +00:00
Anthony Williams
e00b764454 The signature of _interlockedbittestandset changes between MSVC 2005 and MSVC 2008
[SVN r45689]
2008-05-23 19:53:06 +00:00
Anthony Williams
999613c686 Added note about mutex not being recursive
[SVN r45688]
2008-05-23 19:33:18 +00:00
Anthony Williams
c2661d7eb5 define intrusive_ptr_add_ref and intrusive_ptr_release at namespace scope rather than inline as friends in order to try and avoid compiler problems
[SVN r45682]
2008-05-23 15:18:19 +00:00
Anthony Williams
4d21dd1f47 try_lock_wrapper implements operator! in order to try and avoid compiler problems
[SVN r45681]
2008-05-23 15:17:14 +00:00
Anthony Williams
a0a0e57527 Fixed #ifdef to actually use BTS primitives on MSVC 9
[SVN r45676]
2008-05-23 13:16:01 +00:00
Anthony Williams
d8af0d0b4e Reset thread_info on move rather than assigning 0
[SVN r45672]
2008-05-23 10:48:07 +00:00
Anthony Williams
113288e3b0 tidying up move
[SVN r45661]
2008-05-22 16:33:34 +00:00
Anthony Williams
afecfd7c2d Refactored boost::thread code to try and remove duplication
[SVN r45647]
2008-05-22 11:49:48 +00:00
Anthony Williams
94d89aac5f more rvalue reference stuff
[SVN r45626]
2008-05-21 21:11:30 +00:00
Anthony Williams
8831b13efc Use lock_guard<> instead of unique_lock<> internally. Clear out generations after notify_all, as they're all notified
[SVN r45625]
2008-05-21 21:10:45 +00:00
Peter Dimov
01f99da03a Extended boost::thread to 9 arguments, hopefully fixed member function ambiguity.
[SVN r45621]
2008-05-21 20:44:08 +00:00
Anthony Williams
080654e3ef New tests for a normal function with one argument, and a member function with 0 or 1 arguments
[SVN r45607]
2008-05-21 13:38:04 +00:00
Anthony Williams
2ac2eb2a61 try_lock_wrapper has its own operator bool_type to avoid problems with a using declaration
[SVN r45602]
2008-05-21 10:39:47 +00:00
Anthony Williams
61b940b705 Renamed namespace user to user_test_ns to try and avoid a name clash on some platforms
[SVN r45601]
2008-05-21 09:51:53 +00:00
Anthony Williams
4a4f87e017 support for a generic lock() function
[SVN r45481]
2008-05-18 09:10:20 +00:00
Anthony Williams
6d5e7f63a7 Added beginnings of real rvalue-reference support
[SVN r45479]
2008-05-18 08:45:44 +00:00
Anthony Williams
f77285f375 Updated docs to make it explicit that terminate is called if a thread function throws an exception
[SVN r45294]
2008-05-12 09:04:02 +00:00
Anthony Williams
dc5d03a6dc Cleaned up to remove warnings
[SVN r45244]
2008-05-09 07:59:57 +00:00
Anthony Williams
ea0961b7f6 Fixed type truncation warning
[SVN r45243]
2008-05-09 07:49:22 +00:00
Anthony Williams
33d9f9774c Test and fix for bug #1905
[SVN r45242]
2008-05-09 07:48:44 +00:00
Anthony Williams
86097fa038 Use _WIN32 rather than WIN32 to prevent include of <unistd.h>
[SVN r45241]
2008-05-09 07:47:14 +00:00
Anthony Williams
70d9dbc45a Added default constructor to lock types
[SVN r45212]
2008-05-08 14:34:40 +00:00
Anthony Williams
3926fd3a20 Added docs for native_handle
[SVN r45211]
2008-05-08 12:59:59 +00:00
Anthony Williams
7861cf1146 Added native_handle to mutex types where possible
[SVN r45210]
2008-05-08 12:59:10 +00:00
Anthony Williams
0516b86a6e new BTS-based mutex implementation on win32
[SVN r45119]
2008-05-04 22:39:52 +00:00
Anthony Williams
ec735d3e9b Simplified move support
[SVN r45108]
2008-05-04 09:52:54 +00:00
Anthony Williams
1c5c070983 Updated locks.hpp to work with gcc as well as msvc
[SVN r44846]
2008-04-28 12:26:27 +00:00
Anthony Williams
a5c02b73dc Added entry to breaking changes about default-constructed threads and the current thread: issue #1835
[SVN r44840]
2008-04-28 09:10:38 +00:00
Anthony Williams
918b920670 Added detail::try_lock_wrapper for use as scoped_try_lock typedefs, to fix issue #1873
[SVN r44838]
2008-04-28 09:00:58 +00:00
Anthony Williams
de67d2e27e Fixed g++ compile error
[SVN r44773]
2008-04-26 07:34:46 +00:00
Anthony Williams
bc89df04cb Revamped condition variable to try and fix swallowed-notify problems (trac issue #1834)
[SVN r44699]
2008-04-21 16:22:16 +00:00
Anthony Williams
c26a4cf082 added private copy assignment operator and copy constructor to remove warnings
[SVN r44698]
2008-04-21 16:20:31 +00:00
Anthony Williams
6e1a866b13 Fix for issue #1657
[SVN r44424]
2008-04-14 21:04:33 +00:00
Anthony Williams
f91986ad0d Added extended adopt/defer/try constructors to upgrade_lock
[SVN r44370]
2008-04-13 15:50:08 +00:00
Anthony Williams
795cc23f3e Added test and fix for win32 condition_variable broadcast bug similar to #1803
[SVN r44168]
2008-04-11 08:52:09 +00:00
Anthony Williams
a3695bd4a0 Updated thread.hpp as catch-all header
[SVN r44153]
2008-04-10 18:34:42 +00:00
Anthony Williams
08dc521daf Added native_handle to condition_variable on pthreads
[SVN r44152]
2008-04-10 15:52:01 +00:00
Anthony Williams
8b916d21b1 added tests for plain timed_lock on shared_mutex
[SVN r44150]
2008-04-10 14:15:26 +00:00
Anthony Williams
c40f47a78a added overloads of timed_lock_shared with a relative timeout to shared_mutex
[SVN r44149]
2008-04-10 14:07:39 +00:00
Anthony Williams
e9fb470b06 Added native_handle to thread on posix platforms
[SVN r44148]
2008-04-10 13:35:07 +00:00
Anthony Williams
343d049772 fix for trac ticket #1804
[SVN r44147]
2008-04-10 13:27:44 +00:00
Anthony Williams
86f9480da4 fix for notify problem in trac ticket #1803
[SVN r44146]
2008-04-10 13:14:43 +00:00
Anthony Williams
8696b610ca Added test for trac ticket #1803: condition_variable::notify_one may fail to wake a waiting thread on win32
[SVN r44136]
2008-04-09 19:33:06 +00:00
Anthony Williams
6f13227eda Added locked-> owns_lock change to breaking changes
[SVN r44089]
2008-04-07 13:09:36 +00:00
Anthony Williams
58d5110e61 removed forward declaration for undefined type exclusive_lock
[SVN r43847]
2008-03-24 21:44:36 +00:00
Anthony Williams
76e53c7bc5 Removed some warnings: those from issue #1640 and others
[SVN r43730]
2008-03-19 17:25:13 +00:00
Anthony Williams
cfb08be1a8 New documentation for new thread library
[SVN r43671]
2008-03-17 10:29:27 +00:00
Anthony Williams
b5bbb7fb1c Test and fix for bug #1693 to ensure thread_specific_ptr works as desired
[SVN r43666]
2008-03-17 08:36:09 +00:00
Anthony Williams
a76c33f8cc made the callable_no_args function object a named object rather than a temporary, in order to avoid gratuitous breakage on some compilers
[SVN r43528]
2008-03-06 07:59:16 +00:00
Anthony Williams
810306b8f3 thread constructor now accepts up to three additional arguments to pass to thread function
[SVN r43464]
2008-03-03 10:52:44 +00:00
Anthony Williams
6c22bdb3bd Test and fix for issue #1665
[SVN r43461]
2008-03-03 08:44:42 +00:00
Daniel James
6a0d3e98bc Fix broken copyright urls. Fixes #1573.
[SVN r43422]
2008-02-27 18:51:14 +00:00
Anthony Williams
3809321037 added test for duration overloads of timed_lock, and added missing implementation to win32 version
[SVN r43094]
2008-02-04 13:16:32 +00:00
Anthony Williams
eef695bdf0 Provide tss_cleanup_implemented as a dummy function on Windows CE to allow tests to run
[SVN r42818]
2008-01-16 15:23:36 +00:00
Anthony Williams
ab01ab1e4d removed references to NULL
[SVN r42657]
2008-01-10 14:19:36 +00:00
Anthony Williams
c8d8a108a7 Updated thread ID test
[SVN r42228]
2007-12-21 10:54:59 +00:00
Anthony Williams
7afd9efcc5 added hardware_concurrency support for apple, freebsd and sun platforms
[SVN r42195]
2007-12-20 08:37:02 +00:00
Anthony Williams
56ded87ad2 added missing parentheses
[SVN r42194]
2007-12-20 07:46:00 +00:00
Anthony Williams
82e503339b Implement hardware_concurrency for pthread
[SVN r42168]
2007-12-19 10:45:01 +00:00
Anthony Williams
713d0c7ace Updated thread ID, and added tests
[SVN r42166]
2007-12-19 10:39:45 +00:00
Anthony Williams
25ad6e3f8f boost::move support for locks
[SVN r42118]
2007-12-17 12:52:50 +00:00
Anthony Williams
df0197b617 Updated move function test to be fair to Borland
[SVN r42117]
2007-12-17 11:24:13 +00:00
Anthony Williams
a89c4f01ad explicit move functions for threads, with a test
[SVN r42087]
2007-12-15 22:36:43 +00:00
Anthony Williams
ae67099633 added timed_wait overloads that take a duration
[SVN r42086]
2007-12-15 22:34:30 +00:00
Anthony Williams
57542d3a5c fixed order of comparison in timeout check
[SVN r41819]
2007-12-07 08:11:11 +00:00
Anthony Williams
9a1da14116 improved timeout checks
[SVN r41741]
2007-12-05 10:58:45 +00:00
Anthony Williams
ed050d753d added missing include of detail/config.hpp
[SVN r41738]
2007-12-05 08:27:44 +00:00
Anthony Williams
8bec363710 changed order of declaration to eliminate warnings
[SVN r41687]
2007-12-04 14:07:01 +00:00
Anthony Williams
7c68e190a9 Added test for thread move constructor; implemented move on pthreads
[SVN r41686]
2007-12-04 13:02:58 +00:00
Anthony Williams
7ebf5ea3d1 add explicit casts to remove warnings
[SVN r41684]
2007-12-04 12:08:38 +00:00
Anthony Williams
11e0435a4b don't dllexport/dllimport inline functions
[SVN r41683]
2007-12-04 11:44:25 +00:00
Anthony Williams
d15ee57cd1 split shared mutex tests in two to take less time
[SVN r41682]
2007-12-04 10:04:30 +00:00
Anthony Williams
56d660b7fd changed boost::move to boost::detail::thread_move to fix issue #1492
[SVN r41681]
2007-12-04 09:15:37 +00:00
Anthony Williams
792958e693 fixed typo in condition_variable_any::timed_wait
[SVN r41679]
2007-12-04 07:57:23 +00:00
Anthony Williams
914e67dc04 check predicate before returning if we time out on a predicated version of timed_wait
[SVN r41668]
2007-12-03 22:00:26 +00:00
Anthony Williams
b50a7ccb61 interruptible_wait (and hence condition timed_wait) now uses a WaitableTimer where possible, to be robust in the face of clock changes
[SVN r41505]
2007-11-30 18:38:21 +00:00
Anthony Williams
f827709d42 add support for relative timeouts to condition timed_wait
[SVN r41413]
2007-11-27 14:24:29 +00:00
Anthony Williams
36abb42175 reverted accidental checkin of new timed_wait functions on condition_variable
[SVN r41405]
2007-11-26 21:15:04 +00:00
Anthony Williams
40f3b1b4c8 once_flag uses zero-initialization on POSIX as well as windows
[SVN r41401]
2007-11-26 17:01:08 +00:00
Anthony Williams
4f35e25688 fixed import/export declarations so new once code works with pthread-win32
[SVN r41398]
2007-11-26 15:44:07 +00:00
Anthony Williams
270e88edd7 Don't compare native_handle_t against 0 --- do appropriate checks in create_native_thread for platforms where pthread_t is not comparable
[SVN r41396]
2007-11-26 13:29:15 +00:00
Anthony Williams
5ded171247 workaround for Borland compiler
[SVN r41395]
2007-11-26 12:17:45 +00:00
665 changed files with 88802 additions and 5934 deletions

40
.gitignore vendored Normal file
View File

@@ -0,0 +1,40 @@
#mac
.DS_Store
#projects
.project
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
bin/*
test/bin/*
*.exe
*.out
*.app
#doc
doc/html

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
thread
======
Portable C++ multi-threading. C++11, C++14.
### License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

View File

@@ -1,6 +1,7 @@
# $Id$
# Copyright 2006-2007 Roland Schwarz.
# Copyright 2007 Anthony Williams
# Copyright 2011-2012 Vicente J.Botet Escriba.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@@ -35,16 +36,109 @@ import os ;
import feature ;
import indirect ;
import path ;
import configure ;
project boost/thread
: source-location ../src
: requirements <threading>multi
#<link>static:<define>BOOST_THREAD_STATIC_LINK=1
#<link>shared:<define>BOOST_THREAD_DYN_LINK=1
<link>static:<define>BOOST_THREAD_BUILD_LIB=1
<link>shared:<define>BOOST_THREAD_BUILD_DLL=1
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@$(__name__).tag
<toolset>gcc:<cxxflags>-Wno-long-long
: default-build <threading>multi
#<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
#<define>BOOST_SYSTEM_NO_DEPRECATED
#<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
<library>/boost/system//boost_system
#-pedantic -ansi -std=gnu++0x -Wextra -fpermissive
<warnings>all
<toolset>gcc:<cxxflags>-Wextra
<toolset>gcc:<cxxflags>-pedantic
<toolset>gcc:<cxxflags>-Wno-long-long
#<toolset>gcc:<cxxflags>-ansi
#<toolset>gcc:<cxxflags>-fpermissive
<toolset>gcc-4:<cxxflags>-Wno-variadic-macros
<toolset>gcc-5:<cxxflags>-Wno-variadic-macros
#<toolset>gcc:<cxxflags>-Wunused-local-typedefs
<toolset>gcc:<cxxflags>-Wunused-function
<toolset>gcc:<cxxflags>-Wno-unused-parameter
<toolset>darwin:<cxxflags>-Wextra
<toolset>darwin:<cxxflags>-pedantic
#<toolset>darwin:<cxxflags>-ansi
<toolset>darwin:<cxxflags>-fpermissive
<toolset>darwin:<cxxflags>-Wno-long-long
#<toolset>darwin:<cxxflags>-Wno-variadic-macros
<toolset>darwin-4:<cxxflags>-Wno-variadic-macros
<toolset>darwin-5:<cxxflags>-Wno-variadic-macros
#<toolset>darwin:<cxxflags>-Wunused-local-typedefs
<toolset>darwin:<cxxflags>-Wunused-function
<toolset>darwin:<cxxflags>-Wno-unused-parameter
#<toolset>pathscale:<cxxflags>-Wextra
<toolset>pathscale:<cxxflags>-Wno-long-long
<toolset>pathscale:<cxxflags>-pedantic
<toolset>clang:<warnings>on
<toolset>clang:<cxxflags>-Wextra
#<toolset>clang:<cxxflags>-ansi
#<toolset>clang:<cxxflags>-fpermissive
<toolset>clang:<cxxflags>-Wno-long-long
<toolset>clang:<cxxflags>-Wunused-function
<toolset>clang:<cxxflags>-Wno-variadic-macros
<toolset>clang:<cxxflags>-Wno-unused-parameter
#<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.6.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.6.3:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.7.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.8.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc:<cxxflags>-Wno-missing-field-initializers
<toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor
<toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>clang-2.8:<cxxflags>-Wno-unused-function
#<toolset>clang-2.9:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>clang-2.9:<cxxflags>-Wno-unused-function
<toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>clang-3.0:<cxxflags>-Wno-unused-function
#<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
# Note: Some of the remarks from the Intel compiler are disabled
# remark #193: zero used for undefined preprocessing identifier "XXX"
# remark #304: access control not specified ("public" by default)
# remark #593: variable "XXX" was set but never used
# remark #1418: external function definition with no prior declaration
# remark #2415: variable "XXX" of static storage duration was declared but never referenced
<toolset>intel:<cxxflags>-wd193,304,383,444
<toolset>intel:<cxxflags>-wd593,981
<toolset>intel:<cxxflags>-wd1418
<toolset>intel:<cxxflags>-wd2415
<toolset>msvc:<cxxflags>/wd4100
<toolset>msvc:<cxxflags>/wd4512
<toolset>msvc:<cxxflags>/wd6246
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
<target-os>windows:<define>BOOST_USE_WINDOWS_H
# : default-build <threading>multi
: usage-requirements # pass these requirement to dependents (i.e. users)
#<link>static:<define>BOOST_THREAD_STATIC_LINK=1
#<link>shared:<define>BOOST_THREAD_DYN_LINK=1
<link>static:<define>BOOST_THREAD_BUILD_LIB=1
<link>shared:<define>BOOST_THREAD_BUILD_DLL=1
#<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
#<define>BOOST_SYSTEM_NO_DEPRECATED
#<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
<library>/boost/system//boost_system
;
local rule default_threadapi ( )
@@ -57,22 +151,24 @@ local rule default_threadapi ( )
feature.feature threadapi : pthread win32 : propagated ;
feature.set-default threadapi : [ default_threadapi ] ;
exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ;
rule tag ( name : type ? : property-set )
{
local result = $(name) ;
if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
{
local api = [ $(property-set).get <threadapi> ] ;
# non native api gets additional tag
if $(api) != [ default_threadapi ] {
result = $(result)_$(api) ;
}
}
# forward to the boost tagging rule
return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
$(result) : $(type) : $(property-set) ] ;
}
@@ -130,7 +226,7 @@ rule win32_pthread_paths ( properties * )
.notified = true ;
}
}
else
else
{
result += <include>$(include_path) ;
result += <library>$(lib_path) ;
@@ -152,6 +248,12 @@ rule usage-requirements ( properties * )
# in that case?
}
}
#if ! <toolset>vacpp in $(properties) || <toolset-vacpp:version>11.1 in $(properties) || <toolset-vacpp:version>12.1.0.1 in $(properties) || <toolset-vacpp:version>12.1 in $(properties)
#{
result += <library>/boost/chrono//boost_chrono ;
#}
return $(result) ;
}
@@ -162,7 +264,7 @@ rule requirements ( properties * )
if <threadapi>pthread in $(properties)
{
result += <define>BOOST_THREAD_POSIX ;
if <target-os>windows in $(properties)
if <target-os>windows in $(properties)
{
local paths = [ win32_pthread_paths $(properties) ] ;
if $(paths)
@@ -174,7 +276,16 @@ rule requirements ( properties * )
result = <build>no ;
}
}
result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
if ! [ configure.builds has_atomic_flag_lockfree
: $(properties) : "lockfree boost::atomic_flag" ] {
result += <library>/boost/atomic//boost_atomic ;
}
} else {
result += <define>BOOST_THREAD_USES_CHRONO ;
result += <library>/boost/chrono//boost_chrono ;
}
return $(result) ;
}
@@ -183,6 +294,7 @@ alias thread_sources
win32/thread.cpp
win32/tss_dll.cpp
win32/tss_pe.cpp
future.cpp
: ## requirements ##
<threadapi>win32
;
@@ -191,6 +303,7 @@ alias thread_sources
: ## pthread sources ##
pthread/thread.cpp
pthread/once.cpp
future.cpp
: ## requirements ##
<threadapi>pthread
;
@@ -205,3 +318,5 @@ lib boost_thread
<link>static:<define>BOOST_THREAD_USE_LIB=1
<conditional>@usage-requirements
;
boost-install boost_thread ;

View File

@@ -0,0 +1,13 @@
// Copyright (c) 2013, Petr Machata, Red Hat Inc.
//
// Use modification and distribution are subject to the boost Software
// License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
#include "../../../boost/atomic.hpp"
#include "../../../boost/static_assert.hpp"
int main(int argc, char *argv[])
{
BOOST_STATIC_ASSERT(BOOST_ATOMIC_FLAG_LOCK_FREE);
return 0;
}

View File

@@ -1,4 +1,5 @@
# (C) Copyright 2008 Anthony Williams
# (C) Copyright 2008-11 Anthony Williams
# (C) Copyright 2011-12 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)
@@ -15,17 +16,25 @@ boostbook standalone
# Use graphics not text for navigation:
<xsl:param>navig.graphics=1
# How far down we chunk nested sections, basically all of them:
<xsl:param>chunk.section.depth=3
<xsl:param>chunk.section.depth=2
# Don't put the first section on the same page as the TOC:
<xsl:param>chunk.first.sections=1
# How far down sections get TOC's
<xsl:param>toc.section.depth=10
<xsl:param>toc.section.depth=4
# Max depth in each TOC:
<xsl:param>toc.max.depth=3
<xsl:param>toc.max.depth=2
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=10
# Path for links to Boost:
<xsl:param>boost.root=../../../..
;
###############################################################################
alias boostdoc
: thread
:
:
: ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;

View File

@@ -1,5 +1,6 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2012-2015 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).

1771
doc/async_executors.qbk Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,12 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2013-2015 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).
]
[section:barriers Barriers]
[section:barriers Barriers -- EXTENSION]
A barrier is a simple concept. Also known as a ['rendezvous], it is a synchronization point between multiple threads. The barrier is
configured for a particular number of threads (`n`), and as threads reach the barrier they must wait until all `n` threads have
@@ -18,15 +19,22 @@ arrived. Once the `n`-th thread has reached the barrier, all the waiting threads
class barrier
{
public:
barrier(barrier const&) = delete;
barrier& operator=(barrier const&) = delete;
barrier(unsigned int count);
template <typename F>
barrier(unsigned int count, F&&);
~barrier();
bool wait();
void count_down_and_wait();
};
Instances of __barrier__ are not copyable or movable.
[heading Constructor]
[section Constructor `barrier(unsigned int)`]
barrier(unsigned int count);
@@ -38,7 +46,24 @@ Instances of __barrier__ are not copyable or movable.
]
[heading Destructor]
[endsect]
[section Constructor `barrier(unsigned int, F&&)`]
barrier(unsigned int count, F&& completion);
[variablelist
[[Requires:] [The result type of the completion function call `completion()` is `void` or `unsigned int`.]]
[[Effects:] [Construct a barrier for `count` threads and a completion function `completion`.]]
[[Throws:] [__thread_resource_error__ if an error occurs.]]
]
[endsect]
[section Destructor `~barrier()`]
~barrier();
@@ -52,21 +77,55 @@ Instances of __barrier__ are not copyable or movable.
]
[heading Member function `wait`]
[endsect]
[section Member Function `wait()`]
bool wait();
[variablelist
[[Effects:] [Block until `count` threads have called `wait` on `*this`. When the `count`-th thread calls `wait`, all waiting threads
are unblocked, and the barrier is reset. ]]
[[Effects:] [Block until `count` threads have called `wait` or `count_down_and_wait` on `*this`. When the `count`-th thread calls `wait`, the barrier is reset and all waiting threads are unblocked.
The reset depends on whether the barrier was constructed with a completion function or not. If there is no completion function or if the completion function result is void, the reset consists in restoring the original count. Otherwise the rest consist in assigning the result of the completion function (which must not be 0).]]
[[Returns:] [`true` for exactly one thread from each batch of waiting threads, `false` otherwise.]]
[[Throws:] [__thread_resource_error__ if an error occurs.]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`wait()` is an ['interruption point].]]
]
[endsect]
[section Member Function `count_down_and_wait()`]
void count_down_and_wait();
[variablelist
[[Effects:] [Block until `count` threads have called `wait` or `count_down_and_wait` on `*this`. When the `count`-th thread calls `wait`, the barrier is reset and all waiting threads are unblocked.
The reset depends on whether the barrier was constructed with a completion function or not. If there is no completion function or if the completion function result is void, the reset consists in restoring the original count. Otherwise the rest consist in assigning the result of the completion function (which must not be 0).]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`count_down_and_wait()` is an ['interruption point].]]
]
[endsect]
[endsect]
[endsect]

View File

@@ -1,11 +1,670 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2007-11 Anthony Williams.
(C) Copyright 2011-16 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).
]
[section:changes Changes since boost 1.40]
[section:changes History]
[heading Version 4.7.2 - boost 1.63]
[*Fixed Bugs:]
* fix boost::synchronized_value<>::load()
* fix relational operators of boost::synchronized_value<>
* fix compile failed with boost::user_scheduler
* Fix minor possibility of loosing the notify
[heading Version 4.7.1 - boost 1.62]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
Please define BOOST_THREAD_PATCH to apply the patch that could unfortunately results is a regression as described in [@http://svn.boost.org/trac/boost/ticket/12049 #12049].
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last regression test snapshot.
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/11097 #11097] test_scheduled_tp - ThreadSanitizer: heap-use-after-free
* [@http://svn.boost.org/trac/boost/ticket/11951 #11951] Memory leak in boost::when_all
* [@http://svn.boost.org/trac/boost/ticket/12102 #12102] condition_variable_fwd.hpp fails to compile when BOOST_THREAD_PROVIDES_INTERRUPTIONS is disabled
* [@http://svn.boost.org/trac/boost/ticket/12120 #12120] Performance improvement in thread/barrier.hpp
* [@http://svn.boost.org/trac/boost/ticket/12146 #12146] make_exceptional_future is not mentioned in the docs
* [@http://svn.boost.org/trac/boost/ticket/12202 #12202] shared_lock should be in shared_mutex header
* [@http://svn.boost.org/trac/boost/ticket/12220 #12220] Memory leak in future::then()
* [@http://svn.boost.org/trac/boost/ticket/12293 #12293] boost::future::then lambda called before future is ready.
* [@http://svn.boost.org/trac/boost/ticket/12350 #12350] shared_mutex (pthreads) unlocked too early in unlock_shared()
* [@http://svn.boost.org/trac/boost/ticket/12371 #12371] boost thread/future.hpp fails to build
and several PR
* #88 fix typos in boost::upgrade_lock
* #89 fix a bug in upgrade_to_unique_lock<>::operator=()
* #90 fix a bug in try_lock_wrapper<>::operator=()
* #91 Add shared_lock_guard to the included lock types
* #92 Fixed compilation with MSVC-8.
* #93 Fix variable shadowing warnings (Clang)
* #94 fix bugs in boost::barrier
* #95 fix a mistake in boost::completion_latch
* #96 rename async_func.hpp to invoker.hpp.
* #97 fix a mistake in sync_timed_queue<>::pull_until()
[heading Version 4.7.0 - boost 1.61]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
Please define BOOST_THREAD_PATCH to apply the patch that could unfortunately results is a regression as described in [@http://svn.boost.org/trac/boost/ticket/12049 #12049].
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9118 #9118] Seg fault on thread join when llvm and libc++ are used
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last regression test snapshot.
[*New Experimental Features:]
* [@http://svn.boost.org/trac/boost/ticket/11772 #11772] Add a launch::sync policy
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/11494 #11494] boost::this_thread::yield() is marked as deprecated in the synopsis
* [@http://svn.boost.org/trac/boost/ticket/11562 #11562] (condition_variable_any::wait_until + recursive_mutex + steady_clock) timer expires after computer time is set forward on Ubuntu 64-bit
* [@http://svn.boost.org/trac/boost/ticket/12013 #12013] F_pass and FArgs_pass tests segfault
* [@http://svn.boost.org/trac/boost/ticket/12036 #12036] boost::physical_concurrency always returns 0 if BOOST_USE_WINAPI_VERSION is not defined
[heading Version 4.6.0 - boost 1.60]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9118 #9118] Seg fault on thread join when llvm and libc++ are used
* [@http://svn.boost.org/trac/boost/ticket/10942 #10942] Boost.Thread fails to build on Cygwin.
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last regression test snapshot.
[*New Experimental Features:]
* [@http://svn.boost.org/trac/boost/ticket/11231 #11231] Allow to set continuation future's destructor behavior to non-blocking
* [@http://svn.boost.org/trac/boost/ticket/11424 #11424] Provide shared_timed_mutex as an alternative name for shared_mutex and deprecate the use of shared_mutex as a timed mutex
* [@http://svn.boost.org/trac/boost/ticket/11734 #11734] future::then(Cont) should be able to execute the continuation on undetermined thread
* [@http://svn.boost.org/trac/boost/ticket/11736 #11736] Allow to use launch::executor on future::then(launch::executor, cont)
* [@http://svn.boost.org/trac/boost/ticket/11737 #11737] Add a launch::inherit policy that can be used on ::then() to use the policy of the parent future
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/6377 #6377] Condition variable blocks when changing time
* [@http://svn.boost.org/trac/boost/ticket/6787 #6787] boost::thread::sleep() hangs if system time is rolled back
* [@http://svn.boost.org/trac/boost/ticket/7665 #7665] this_thread::sleep_for no longer uses steady_clock in thread
* [@http://svn.boost.org/trac/boost/ticket/7720 #7720] exception lock_error while intensive locking/unlocking of mutex
* [@http://svn.boost.org/trac/boost/ticket/9309 #9309] test_latch fails often on clang-darwin-tot11
* [@http://svn.boost.org/trac/boost/ticket/10788 #10788] GetLogicalProcessor isn't available for Windows platform less or equals to 0x0502
* [@http://svn.boost.org/trac/boost/ticket/11090 #11090] ex_future_unwrap- ThreadSanitizer: lock-order-inversion (potential deadlock)
* [@http://svn.boost.org/trac/boost/ticket/11158 #11158] Pthread thread deadlock when faketime used
* [@http://svn.boost.org/trac/boost/ticket/11174 #11174] boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite
* [@http://svn.boost.org/trac/boost/ticket/11185 #11185] Incorrect URL redirection
* [@http://svn.boost.org/trac/boost/ticket/11192 #11192] boost::future<>::then() with an executor doesn't compile when the callback returns a future
* [@http://svn.boost.org/trac/boost/ticket/11250 #11250] future made from make_exceptional fails on assertion in destructor
* [@http://svn.boost.org/trac/boost/ticket/11256 #11256] future<>::is_ready() == false in continuation function
* [@http://svn.boost.org/trac/boost/ticket/11261 #11261] bad use of scoped threads in basic_thread_pool
* [@http://svn.boost.org/trac/boost/ticket/11262 #11262] bad use of direct pointer in shared_state_nullary_task
* [@http://svn.boost.org/trac/boost/ticket/11263 #11263] lock already locked lock
* [@http://svn.boost.org/trac/boost/ticket/11266 #11266] boost::packaged_task has invalid variadic signature
* [@http://svn.boost.org/trac/boost/ticket/11302 #11302] boost thread doesn't build with BOOST_THREAD_PATCH.
* [@http://svn.boost.org/trac/boost/ticket/11322 #11322] sleep_for() nanoseconds overload will always return too early on windows
* [@http://svn.boost.org/trac/boost/ticket/11329 #11329] using declarative for GetProcessHeap, .... fails
* [@http://svn.boost.org/trac/boost/ticket/11368 #11368] boost thread's usage of CreateWaitableTimer wakes PC from sleep (doh)
* [@http://svn.boost.org/trac/boost/ticket/11377 #11377] Boost condition variable always waits for system clock deadline
* [@http://svn.boost.org/trac/boost/ticket/11435 #11435] gcc compiler warning in future.hpp
* [@http://svn.boost.org/trac/boost/ticket/11555 #11555] devector.hpp assumes allocator_traits_type is always present
* [@http://svn.boost.org/trac/boost/ticket/11562 #11562] (condition_variable_any::wait_until + recursive_mutex + steady_clock) timer expires after computer time is set forward on Ubuntu 64-bit
* [@http://svn.boost.org/trac/boost/ticket/11672 #11672] Thread: Should use unique_ptr, not auto_ptr
* [@http://svn.boost.org/trac/boost/ticket/11688 #11688] thread::try_join_until: Avoid busy wait if system clock changes
* [@http://svn.boost.org/trac/boost/ticket/11672 #11716] ::then(f) should inherit the parent Executor
* [@http://svn.boost.org/trac/boost/ticket/11795 #11795] Incorrect version specification for documentation of thread destructor
* [@http://svn.boost.org/trac/boost/ticket/11796 #11796] Thread move assignment operator, does not detach previous thread data
* [@http://svn.boost.org/trac/boost/ticket/11817 #11817] 'sync_queue_is_closed' was not declared in boost/thread/executors/thread_executor.hpp
* [@http://svn.boost.org/trac/boost/ticket/11818 #11818] future.then will be blocked if promise is set after the invocation of then
* [@http://svn.boost.org/trac/boost/ticket/12049 #12049] Assertion failure from detached threads during shutdown
[heading Version 4.5.0 - boost 1.58]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9118 #9118] Seg fault on thread join when llvm and libc++ are used
* [@http://svn.boost.org/trac/boost/ticket/9309 #9309] test_latch fails often on clang-darwin-tot11
* [@http://svn.boost.org/trac/boost/ticket/9311 #9311] ex_lambda_future fails on msvc-11.0
* [@http://svn.boost.org/trac/boost/ticket/10942 #10942] Boost.Thread fails to build on Cygwin.
[/
* [@http://svn.boost.org/trac/boost/ticket/7319 #7319] Take care of c++std-lib-32966 issue
* [@http://svn.boost.org/trac/boost/ticket/10651 #10651] boost::thread leaks memory when using the MinGW compiler.
* [@http://svn.boost.org/trac/boost/ticket/10685 #10685] mfc_thread_init.hpp does not compile.
* [@http://svn.boost.org/trac/boost/ticket/10967 #10967] Timed wait points inconsistently convert relative to absolute waits.
]
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last regression test snapshot.
[*Sever limitations:]
There are some severe bugs that prevent the use of the library on concrete contexts, in particular:
* on thread specific storage that prevent the library to be used with dynamic libraries ( [@http://svn.boost.org/trac/boost/ticket/3926 #3926], ),
[*New Experimental Features:]
* [@http://svn.boost.org/trac/boost/ticket/9600 #9600] Async: Add task_region
* [@http://svn.boost.org/trac/boost/ticket/10611 #10611] Add emplace promise::set_value and emplace make_ready_future
* [@http://svn.boost.org/trac/boost/ticket/10826 #10826] Add scheduled executor operations
* [@http://svn.boost.org/trac/boost/ticket/11048 #11048] Add a serial_executor based on continuations
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/6787 #6787] boost::thread::sleep() hangs if system time is rolled back
* [@http://svn.boost.org/trac/boost/ticket/10734 #10734] Submit method work differently on different executors, some throw exception and some silently ignore error (thread_executor and inline_executor)
* [@http://svn.boost.org/trac/boost/ticket/10736 #10736] Task exceptions silently ignored. I think std::terminate solution from N3785 and std::thread is better choice and more consistent.
* [@http://svn.boost.org/trac/boost/ticket/10737 #10737] In serial_executor we have infinite wait if task throw exception.
* [@http://svn.boost.org/trac/boost/ticket/10822 #10822] Boost.Thread fails to compile on Android
* [@http://svn.boost.org/trac/boost/ticket/10824 #10824] Boost.Thread 1.57 breaks Windows XP compatibility for SP2 and below.
* [@http://svn.boost.org/trac/boost/ticket/10963 #10963] future<future<T>>::then Has No Implementation
* [@http://svn.boost.org/trac/boost/ticket/10964 #10964] future<future<T>>::unwrap().then() Deadlocks
* [@http://svn.boost.org/trac/boost/ticket/10968 #10968] The futures returned by async() and future::then() are not blocking.
* [@http://svn.boost.org/trac/boost/ticket/10971 #10971] shared_future::get()/get_or() must be const
* [@http://svn.boost.org/trac/boost/ticket/10972 #10972] shared_future::then() can be called multiple times.
* [@http://svn.boost.org/trac/boost/ticket/10979 #10979] Support T& type deduction when the make_ready_future parameter is reference_wrapper<T>
* [@http://svn.boost.org/trac/boost/ticket/10996 #10996] Thread physical_concurrency() is failing on Windows
* [@http://svn.boost.org/trac/boost/ticket/11035 #11035] BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE not defined for Android
* [@http://svn.boost.org/trac/boost/ticket/11053 #11053] The attached code results in a R6025 - pure virtual function call in run_thread_exit_callbacks
[heading Version 4.4.0 - boost 1.57]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/2442 #2442] Application statically linked with Boost.Thread crashes when Google Desktop is installed (Windows XP)
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/7319 #7319] Take care of c++std-lib-32966 issue
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9118 #9118] Seg fault on thread join when llvm and libc++ are used
* [@http://svn.boost.org/trac/boost/ticket/9309 #9309] test_latch fails often on clang-darwin-tot11
* [@http://svn.boost.org/trac/boost/ticket/9310 #9310] test_4648_lib fails on clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9311 #9311] ex_lambda_future fails on msvc-11.0
* [@http://svn.boost.org/trac/boost/ticket/10537 #10537] Application crash on throw exception
* [@http://svn.boost.org/trac/boost/ticket/10651 #10651] boost::thread leaks memory when using the MinGW compiler
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last snapshot.
[*Sever limitations:]
There are some severe bugs that prevent the use of the library on concrete contexts, in particular:
* on thread specific storage that prevent the library to be used with dynamic libraries,
[*New Experimental Features:]
* [@http://svn.boost.org/trac/boost/ticket/6227 #6227] Synchro: Use of variadic templates on Generic Locking Algorithms on compilers providing them
* [@http://svn.boost.org/trac/boost/ticket/10298 #10298] Synchro: Added queue views.
* [@http://svn.boost.org/trac/boost/ticket/10300 #10300] Async: Added generic_executor_ref.
* [@http://svn.boost.org/trac/boost/ticket/10552 #10552] Add make_valid_future
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/6782 #6782] call_once uses incorrect barrier intrinsic on Visual Studio
* [@http://svn.boost.org/trac/boost/ticket/6787 #6787] boost::thread::sleep() hangs if system time is rolled back
* [@http://svn.boost.org/trac/boost/ticket/7665 #7665] this_thread::sleep_for no longer uses steady_clock in thread
* [@http://svn.boost.org/trac/boost/ticket/9307 #9307] future::fallback_to assert with ERRORRRRR boost: mutex lock failed in pthread_mutex_lock: Invalid argument
* [@http://svn.boost.org/trac/boost/ticket/9308 #9308] future::async fails with terminate called throwing an exception when called with a lambda - clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9310 #9310] test_4648_lib fails on clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9425 #9425] Boost promise & future does not use supplied allocator for value storage
* [@http://svn.boost.org/trac/boost/ticket/9558 #9558] future continuations unit test hangs in get()/pthread_cond_wait() on Mac 10.7/32-bit/x86/darwin-4.2.1
* [@http://svn.boost.org/trac/boost/ticket/9787 #9787] [windows] Small duration value passed down to basic_timed_mutex::try_lock_until and condition_variable::wait_until can cause infinite or near infinite wait for win32
* [@http://svn.boost.org/trac/boost/ticket/9880 #9880] [windows] boost::condition_variable.timed_wait() exception if system time < 1970
* [@http://svn.boost.org/trac/boost/ticket/10159 #10159] GCC 4.4 error sorry, unimplemented
* [@http://svn.boost.org/trac/boost/ticket/10196 #10196] thread_specific_ptr does not support void*
* [@http://svn.boost.org/trac/boost/ticket/10296 #10296] Boost.Thread 1.56 rc1 does not compile on Mingw
* [@http://svn.boost.org/trac/boost/ticket/10297 #10297] Boost.Thread 1.56 rc1 hangs when built with clang on armhf
* [@http://svn.boost.org/trac/boost/ticket/10340 #10340] No boost::promise<T>::set_value(const T&) overload present in C++03 mode
* [@http://svn.boost.org/trac/boost/ticket/10425 #10425] Missing documentation for when_all/when_any.
* [@http://svn.boost.org/trac/boost/ticket/10426 #10426] Take in account the deferred futures in when_all.
* [@http://svn.boost.org/trac/boost/ticket/10427 #10427] Take in account the deferred and ready futures in when_any.
* [@http://svn.boost.org/trac/boost/ticket/10428 #10428] Adapt to new unique_ptr interface in Boost.Move
* [@http://svn.boost.org/trac/boost/ticket/10465 #10465] Missing implementation of when_all/when_any when the result is a tuple.
* [@http://svn.boost.org/trac/boost/ticket/10476 #10476] classes using BOOST_THREAD_MOVABLE_ONLY<T> dont satisfy is_copy_constructible<T>::value == false
* [@http://svn.boost.org/trac/boost/ticket/10478 #10478] Data race in boost/thread/future.hpp
* [@http://svn.boost.org/trac/boost/ticket/10529 #10529] The pthread/condition_variable_any constructor reports incorrect error code for pthread_cond_init
* [@http://svn.boost.org/trac/boost/ticket/10563 #10563] shared_future<R>::then should be const
[heading Version 4.3.0 - boost 1.56]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/2442 #2442] Application statically linked with Boost.Thread crashes when Google Desktop is installed (Windows XP)
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/6782 #6782] call_once uses incorrect barrier intrinsic on Visual Studio
* [@http://svn.boost.org/trac/boost/ticket/7319 #7319] Take care of c++std-lib-32966 issue
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9307 #9307] future::fallback_to assert with ERRORRRRR boost: mutex lock failed in pthread_mutex_lock: Invalid argument
* [@http://svn.boost.org/trac/boost/ticket/9308 #9308] future::async fails with terminate called throwing an exception when called with a lambda - clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9310 #9310] test_4648_lib fails on clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9311 #9311] ex_lambda_future fails on msvc-11.0
* [@http://svn.boost.org/trac/boost/ticket/9425 #9425] Boost promise & future does not use supplied allocator for value storage
* [@http://svn.boost.org/trac/boost/ticket/9558 #9558] future continuations unit test hangs in get()/pthread_cond_wait() on Mac 10.7/32-bit/x86/darwin-4.2.1
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread Know Bugs] to see the current state.
Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread trunk regression test] to see the last snapshot.
[*Sever limitations:]
There are some severe bugs that prevent the use of the library on concrete contexts, in particular:
* on thread specific storage that prevent the library to be used with dynamic libraries,
* The experimental features of boost::future have some severe holes that make the program crash unexpectedly.
[*New Experimental Features:]
* [@http://svn.boost.org/trac/boost/ticket/7446 #7446] Async: Add when_any.
* [@http://svn.boost.org/trac/boost/ticket/7447 #7447] Async: Add when_all.
* [@http://svn.boost.org/trac/boost/ticket/7448 #7448] Async: Add async taking a scheduler parameter.
* [@http://svn.boost.org/trac/boost/ticket/8274 #8274] Synchro: Add concurrent queue
* [@http://svn.boost.org/trac/boost/ticket/8518 #8518] Synchro: Add a latch class.
* [@http://svn.boost.org/trac/boost/ticket/8513 #8513] Async: Add a basic thread_pool executor.
* [@http://svn.boost.org/trac/boost/ticket/8516 #8516] Async: Add future/shared_future::then taking a scheduler as parameter.
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/8070 #8070] prefer GetTickCount64 over GetTickCount
* [@http://svn.boost.org/trac/boost/ticket/9333 #9333] ex_scoped_thread compile fails on msvc-12.0
* [@http://svn.boost.org/trac/boost/ticket/9366 #9366] async(Executor, ...) fails to compile with msvc-10,11,12
* [@http://svn.boost.org/trac/boost/ticket/9402 #9402] test_excutor regression on msvc-10,11,12
* [@http://svn.boost.org/trac/boost/ticket/9404 #9404] ex_make_future regression error
* [@http://svn.boost.org/trac/boost/ticket/9471 #9471] Synchronization documentation nits
* [@http://svn.boost.org/trac/boost/ticket/9535 #9535] Missing exception safety might result in crash
* [@http://svn.boost.org/trac/boost/ticket/9618 #9618] try_join_for problem: program is not terminate.
* [@http://svn.boost.org/trac/boost/ticket/9673 #9673] thread compilation with MingW/gcc on Windows gives errors
* [@http://svn.boost.org/trac/boost/ticket/9708 #9708] boost::condition_variable::timed_wait unexpectedly wakes up while should wait infinite
* [@http://svn.boost.org/trac/boost/ticket/9711 #9711] future continuation called twice
[heading Version 4.2.0 - boost 1.55]
[*Know Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/2442 #2442] Application statically linked with Boost.Thread crashes when Google Desktop is installed (Windows XP)
* [@http://svn.boost.org/trac/boost/ticket/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
* [@http://svn.boost.org/trac/boost/ticket/4833 #4833] MinGW/test_tss_lib: Support of automatic tss cleanup for native threading API not available
* [@http://svn.boost.org/trac/boost/ticket/6782 #6782] call_once uses incorrect barrier intrinsic on Visual Studio
* [@http://svn.boost.org/trac/boost/ticket/7319 #7319] Take care of c++std-lib-32966 issue
* [@http://svn.boost.org/trac/boost/ticket/8600 #8600] wait_for_any hangs, if called with multiple copies of shared_future referencing same task
* [@http://svn.boost.org/trac/boost/ticket/9307 #9307] future::fallback_to assert with ERRORRRRR boost: mutex lock failed in pthread_mutex_lock: Invalid argument
* [@http://svn.boost.org/trac/boost/ticket/9308 #9308] future::async fails with terminate called throwing an exception when called with a lambda - clang-darwin-asan11
* [@http://svn.boost.org/trac/boost/ticket/9311 #9311] ex_lambda_future fails on msvc-11.0
* [@http://svn.boost.org/trac/boost/ticket/9310 #9310] test_4648_lib fails on clang-darwin-asan11
Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=thread&type=!Feature+Requests&col=id&col=summary&order=id thread trunk regression test] to see the current state.
[*Sever limitations:]
There are some severe bugs that prevent the use of the library on concrete contexts, in particular:
* on thread specific storage that prevent the library to be used with dynamic libraries,
* The experimental features of boost::future have some severe holes that make the program crash unexpectedly.
[*New Features:]
* [@http://svn.boost.org/trac/boost/ticket/8519 #8519] Synchro: Update class barrier with a completion function.
* [@http://svn.boost.org/trac/boost/ticket/8515 #8515] Async: Add shared_future::then.
* [@http://svn.boost.org/trac/boost/ticket/8519 #8519] Synchro: Update class barrier with a completion function
* [@http://svn.boost.org/trac/boost/ticket/8615 #8615] Async: Replace make_future/make_shared_future by make_ready_future.
* [@http://svn.boost.org/trac/boost/ticket/8627 #8627] Async: Add future<>::unwrap and unwrapping constructor.
* [@http://svn.boost.org/trac/boost/ticket/8677 #8677] Async: Add future<>::get_or.
* [@http://svn.boost.org/trac/boost/ticket/8678 #8678] Async: Add future<>::fallback_to.
* [@http://svn.boost.org/trac/boost/ticket/8891 #8891] upgrade_to_unique_lock: missing mutex() function.
* [@http://svn.boost.org/trac/boost/ticket/8955 #8955] Request for more efficient way to get exception_ptr from future.
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/7461 #7461] detail::win32::ReleaseSemaphore may be called with count_to_release equal to 0
* [@http://svn.boost.org/trac/boost/ticket/8070 #8070] prefer GetTickCount64 over GetTickCount
* [@http://svn.boost.org/trac/boost/ticket/8768 #8768] win32 condition_variable::wait_until infinite wait in rare cases.
* [@http://svn.boost.org/trac/boost/ticket/8817 #8817] Boost Thread Windows CE _createthreadex handling breaks mingw w64.
* [@http://svn.boost.org/trac/boost/ticket/8943 #8943] Failed to compile code using boost::call_once with Intel C++ Composer XE 2013 on Windows.
* [@http://svn.boost.org/trac/boost/ticket/8931 #8931] Typos in external_locking reference.
* [@http://svn.boost.org/trac/boost/ticket/9029 #9029] Misprint in documentation.
* [@http://svn.boost.org/trac/boost/ticket/9037 #9037] gcc -Wshadow gives warnings in condition_variable{,_fwd}.hpp.
* [@http://svn.boost.org/trac/boost/ticket/9041 #9041] Boost.Thread DSO's may need to link with Boost.Atomic.
* [@http://svn.boost.org/trac/boost/ticket/9048 #9048] boost::scoped_thread useless ctor with variadic template arguments.
* [@http://svn.boost.org/trac/boost/ticket/9079 #9079] Condition variable will wait forever for some timepoint values (Win).
[heading Version 4.1.0 - boost 1.54]
[*New Features:]
* [@http://svn.boost.org/trac/boost/ticket/7285 #7285] C++11 compliance: Allow to pass movable arguments for call_once.
* [@http://svn.boost.org/trac/boost/ticket/7445 #7445] Async: Add future<>.then
* [@http://svn.boost.org/trac/boost/ticket/7449 #7449] Synchro: Add a synchronized value class
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/4878 #4878] MinGW 4.5.0 undefined reference to bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::t imeout target_time).
* [@http://svn.boost.org/trac/boost/ticket/4882 #4882] Win32 shared_mutex does not handle timeouts correctly.
* [@http://svn.boost.org/trac/boost/ticket/5752 #5752] boost::call_once() is unreliable on some platforms
* [@http://svn.boost.org/trac/boost/ticket/6652 #6652] Boost.Thread shared_mutex.hpp:50:99: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
* [@http://svn.boost.org/trac/boost/ticket/6843 #6843] [Intel C++] Compile Errors with '#include <atomic>'
* [@http://svn.boost.org/trac/boost/ticket/6966 #6966] future boost::future_category inconsistent dll linkage
* [@http://svn.boost.org/trac/boost/ticket/7720 #7720] exception lock_error while intensive locking/unlocking of mutex
* [@http://svn.boost.org/trac/boost/ticket/7755 #7755] Thread: deadlock with shared_mutex on Windows
* [@http://svn.boost.org/trac/boost/ticket/7980 #7980] Build error: msvc-11.0 and BOOST_THREAD_DONT_USE_DATETIME
* [@http://svn.boost.org/trac/boost/ticket/7982 #7982] pthread_delay_np() parm compile error on AIX
* [@http://svn.boost.org/trac/boost/ticket/8027 #8027] thread library fails to compile with Visual Studio 2003
* [@http://svn.boost.org/trac/boost/ticket/8070 #8070] prefer GetTickCount64 over GetTickCount
* [@http://svn.boost.org/trac/boost/ticket/8136 #8136] boost::this_thread::sleep_for() sleeps longer than it should in Windows
* [@http://svn.boost.org/trac/boost/ticket/8212 #8212] Boost thread compilation error on Solaris 10
* [@http://svn.boost.org/trac/boost/ticket/8237 #8237] fix documentation for 'thread_group'
* [@http://svn.boost.org/trac/boost/ticket/8239 #8239] barrier::wait() not marked as interruption_point
* [@http://svn.boost.org/trac/boost/ticket/8323 #8323] boost::thread::try_join_for/try_join_until may block indefinitely due to a combination of problems in Boost.Thread and Boost.Chrono
* [@http://svn.boost.org/trac/boost/ticket/8337 #8337] The internal representation of "std::string(this->code()->message())" escapes, but is destroyed when it exits scope.
* [@http://svn.boost.org/trac/boost/ticket/8371 #8371] C++11 once_flag enabled when constexpr is not available
* [@http://svn.boost.org/trac/boost/ticket/8422 #8422] Assertion in win32::WaitForSingleObject()
* [@http://svn.boost.org/trac/boost/ticket/8443 #8443] Header file inclusion order may cause crashes
* [@http://svn.boost.org/trac/boost/ticket/8451 #8451] Missing documented function 'boost::scoped_thread::joinable'
* [@http://svn.boost.org/trac/boost/ticket/8458 #8458] -DBOOST_THREAD_DONT_USE_CHRONO in thread.obj.rsp but not explicitly set
* [@http://svn.boost.org/trac/boost/ticket/8530 #8530] [Coverity] Unused variable thread_handle, uninitialized variable cond_mutex in thread/pthread/thread_data.hpp
* [@http://svn.boost.org/trac/boost/ticket/8550 #8550] static linking of Boost.Thread with an MFC-Dll
* [@http://svn.boost.org/trac/boost/ticket/8576 #8576] "sur parolle" should be "sur parole".
* [@http://svn.boost.org/trac/boost/ticket/8596 #8596] With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy.
* [@http://svn.boost.org/trac/boost/ticket/8626 #8626] Reintroduce BOOST_VERIFY on pthread_mutex_destroy return type
* [@http://svn.boost.org/trac/boost/ticket/8645 #8645] Typo in Strict lock definition
* [@http://svn.boost.org/trac/boost/ticket/8671 #8671] promise: set_..._at_thread_exit
* [@http://svn.boost.org/trac/boost/ticket/8672 #8672] future<>::then(void()) doesn't works
* [@http://svn.boost.org/trac/boost/ticket/8674 #8674] Futures as local named objects can't be returned with implicit move.
[heading Version 4.0.0 - boost 1.53]
[/
[*Breaking changes:]
[warning
BOOST_THREAD_VERSION==3 by default since Boost 1.53. So that all the deprecated features since 1.50 are not included by default. You can change this by setting the appropriated define (see Configuration section).
]
]
[*Deprecated features:]
[warning Deprecated features since boost 1.53 will be available only until boost 1.58.]
* C++11 compliance: packaged_task<R> is deprecated, use instead packaged_task<R()>.
See BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK and BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK
* [@http://svn.boost.org/trac/boost/ticket/7537 #7537] deprecate Mutex::scoped_lock and scoped_try_lock and boost::condition
[*New Features:]
* [@http://svn.boost.org/trac/boost/ticket/6270 #6270] c++11 compliance: Add thread constructor from movable callable and movable arguments
Provided when BOOST_THREAD_PROVIDES_VARIADIC_THREAD is defined (Default value from Boost 1.55):
See BOOST_THREAD_PROVIDES_VARIADIC_THREAD and BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD.
* [@http://svn.boost.org/trac/boost/ticket/7279 #7279] C++11 compliance: Add noexcept in system related functions
* [@http://svn.boost.org/trac/boost/ticket/7280 #7280] C++11 compliance: Add promise::...at_thread_exit functions
* [@http://svn.boost.org/trac/boost/ticket/7281 #7281] C++11 compliance: Add ArgTypes to packaged_task template.
Provided when BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK is defined (Default value from Boost 1.55).
See BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK and BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK.
* [@http://svn.boost.org/trac/boost/ticket/7282 #7282] C++11 compliance: Add packaged_task::make_ready_at_thread_exit function
* [@http://svn.boost.org/trac/boost/ticket/7285 #7285] C++11 compliance: Allow to pass movable arguments for call_once
* [@http://svn.boost.org/trac/boost/ticket/7412 #7412] C++11 compliance: Add async from movable callable and movable arguments
Provided when BOOST_THREAD_PROVIDES_VARIADIC_THREAD and BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK are defined (Default value from Boost 1.55):
See BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK and BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK, BOOST_THREAD_PROVIDES_VARIADIC_THREAD and BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD.
* [@http://svn.boost.org/trac/boost/ticket/7413 #7413] C++11 compliance: Add async when the launch policy is deferred.
* [@http://svn.boost.org/trac/boost/ticket/7414 #7414] C++11 compliance: future::get post-condition should be valid()==false.
* [@http://svn.boost.org/trac/boost/ticket/7422 #7422] Provide a condition variable with zero-overhead performance penality.
* [@http://svn.boost.org/trac/boost/ticket/7414 #7444] Async: Add make_future/make_shared_future.
* [@http://svn.boost.org/trac/boost/ticket/7540 #7540] Threads: Add a helper class that join a thread on destruction.
* [@http://svn.boost.org/trac/boost/ticket/7541 #7541] Threads: Add a thread wrapper class that joins on destruction.
* [@http://svn.boost.org/trac/boost/ticket/7575 #7575] C++11 compliance: A future created by async should "join" in the destructor.
* [@http://svn.boost.org/trac/boost/ticket/7587 #7587] Synchro: Add strict_lock and nested_strict_lock.
* [@http://svn.boost.org/trac/boost/ticket/7588 #7588] Synchro: Split the locks.hpp in several files to limit dependencies.
* [@http://svn.boost.org/trac/boost/ticket/7590 #7590] Synchro: Add lockable concept checkers based on Boost.ConceptCheck.
* [@http://svn.boost.org/trac/boost/ticket/7591 #7591] Add lockable traits that can be used with enable_if.
* [@http://svn.boost.org/trac/boost/ticket/7592 #7592] Synchro: Add a null_mutex that is a no-op and that is a model of UpgardeLockable.
* [@http://svn.boost.org/trac/boost/ticket/7593 #7593] Synchro: Add a externally_locked class.
* [@http://svn.boost.org/trac/boost/ticket/7590 #7594] Threads: Allow to disable thread interruptions.
[*Fixed Bugs:]
* [@http://svn.boost.org/trac/boost/ticket/5752 #5752] boost::call_once() is unreliable on some platforms
* [@http://svn.boost.org/trac/boost/ticket/7464 #7464] BOOST_TEST(n_alive == 1); fails due to race condition in a regression test tool.
* [@http://svn.boost.org/trac/boost/ticket/7657 #7657] Serious performance and memory consumption hit if condition_variable methods condition notify_one or notify_all is used repeatedly.
* [@http://svn.boost.org/trac/boost/ticket/7665 #7665] this_thread::sleep_for no longer uses steady_clock in thread.
* [@http://svn.boost.org/trac/boost/ticket/7668 #7668] thread_group::join_all() should check whether its threads are joinable.
* [@http://svn.boost.org/trac/boost/ticket/7669 #7669] thread_group::join_all() should catch resource_deadlock_would_occur.
* [@http://svn.boost.org/trac/boost/ticket/7671 #7671] Error including boost/thread.hpp header on iOS.
* [@http://svn.boost.org/trac/boost/ticket/7672 #7672] lockable_traits.hpp syntax error: "defined" token misspelled.
* [@http://svn.boost.org/trac/boost/ticket/7798 #7798] boost::future set_wait_callback thread safety issues.
* [@http://svn.boost.org/trac/boost/ticket/7808 #7808] Incorrect description of effects for this_thread::sleep_for and this_thread::sleep_until.
* [@http://svn.boost.org/trac/boost/ticket/7812 #7812] Returns: cv_status::no_timeout if the call is returning because the time period specified by rel_time has elapsed, cv_status::timeout otherwise.
* [@http://svn.boost.org/trac/boost/ticket/7874 #7874] compile warning: thread.hpp:342: warning: type attributes are honored only at type definition.
* [@http://svn.boost.org/trac/boost/ticket/7875 #7875] BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED should not be enabled by default.
* [@http://svn.boost.org/trac/boost/ticket/7882 #7882] wrong exception text from condition_variable::wait(unique_lock<mutex>&).
* [@http://svn.boost.org/trac/boost/ticket/7890 #7890] thread::do_try_join_until() is missing a return type.
[heading Version 3.1.0 - boost 1.52]
Deprecated Features:
Deprecated features since boost 1.50 available only until boost 1.55:
These deprecated features will be provided by default up to boost 1.52. If you don't want to include the deprecated features you could define BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. Since 1.53 these features will not be included any more by default. Since this version, if you want to include the deprecated features yet you could define BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. These deprecated features will be only available until boost 1.55, that is you have yet 1 year to move to the new features.
* Time related functions don't using the Boost.Chrono library, use the chrono overloads instead.
Breaking changes when BOOST_THREAD_VERSION==3 (Default value since Boost 1.53):
There are some new features which share the same interface but with different behavior. These breaking features are provided by default when BOOST_THREAD_VERSION is 3, but the user can however choose the version 2 behavior by defining the corresponding macro. As for the deprecated features, these broken features will be only available until boost 1.55.
* [@http://svn.boost.org/trac/boost/ticket/6229 #6229] Rename the unique_future to future following the c++11.
* [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable.
* [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable.
New Features:
* [@http://svn.boost.org/trac/boost/ticket/2361 #2361] thread_specific_ptr: document nature of the key, complexity and rationale.
* [@http://svn.boost.org/trac/boost/ticket/4710 #4710] C++11 compliance: Missing async().
* [@http://svn.boost.org/trac/boost/ticket/7283 #7283] C++11 compliance: Add notify_all_at_thread_exit.
* [@http://svn.boost.org/trac/boost/ticket/7345 #7345] C++11 compliance: Add noexcept to recursive mutex try_lock.
Fixed Bugs:
* [@http://svn.boost.org/trac/boost/ticket/2797 #2797] Two problems with thread_specific_ptr.
* [@http://svn.boost.org/trac/boost/ticket/5274 #5274] failed to compile future.hpp with stlport 5.1.5 under msvc8.1, because of undefined class.
* [@http://svn.boost.org/trac/boost/ticket/5431 #5431] compile error in Windows CE 6.0(interlocked).
[/* [@http://svn.boost.org/trac/boost/ticket/5752 #5752] boost::call_once() is unreliable on some platforms.]
* [@http://svn.boost.org/trac/boost/ticket/5696 #5696] win32 detail::set_tss_data does nothing when tss_cleanup_function is NULL.
* [@http://svn.boost.org/trac/boost/ticket/6931 #6931] mutex waits forwever with Intel C++ Compiler XE 12.1.5.344 Build 20120612
* [@http://svn.boost.org/trac/boost/ticket/7045 #7045] Thread library does not automatically compile date_time.
* [@http://svn.boost.org/trac/boost/ticket/7173 #7173] wrong function name interrupt_point().
* [@http://svn.boost.org/trac/boost/ticket/7200 #7200] Unable to build boost.thread modularized.
* [@http://svn.boost.org/trac/boost/ticket/7220 #7220] gcc 4.6.2 warns about inline+dllimport functions.
* [@http://svn.boost.org/trac/boost/ticket/7238 #7238] this_thread::sleep_for() does not respond to interrupt().
* [@http://svn.boost.org/trac/boost/ticket/7245 #7245] Minor typos on documentation related to version 3.
* [@http://svn.boost.org/trac/boost/ticket/7272 #7272] win32/thread_primitives.hpp: (Unneccessary) Warning.
* [@http://svn.boost.org/trac/boost/ticket/7284 #7284] Clarify that there is no access priority between lock and shared_lock on shared mutex.
* [@http://svn.boost.org/trac/boost/ticket/7329 #7329] boost/thread/future.hpp does not compile on HPUX.
* [@http://svn.boost.org/trac/boost/ticket/7336 #7336] BOOST_THREAD_DONT_USE_SYSTEM doesn't work.
* [@http://svn.boost.org/trac/boost/ticket/7329 #7349] packaged_task holds reference to temporary.
* [@http://svn.boost.org/trac/boost/ticket/7350 #7350] allocator_destructor does not destroy object
* [@http://svn.boost.org/trac/boost/ticket/7360 #7360] Memory leak in pthread implementation of boost::thread_specific_ptr
* [@http://svn.boost.org/trac/boost/ticket/7370 #7370] Boost.Thread documentation
* [@http://svn.boost.org/trac/boost/ticket/7438 #7438] Segmentation fault in test_once regression test in group.join_all();
* [@http://svn.boost.org/trac/boost/ticket/7461 #7461] detail::win32::ReleaseSemaphore may be called with count_to_release equal to 0
* [@http://svn.boost.org/trac/boost/ticket/7499 #7499] call_once doesn't call even once
[heading Version 3.0.1 - boost 1.51]
Deprecated Features:
Deprecated features since boost 1.50 available only until boost 1.55:
These deprecated features will be provided by default up to boost 1.52. If you don't want to include the deprecated features you could define BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. Since 1.53 these features will not be included any more by default. Since this version, if you want to include the deprecated features yet you could define BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. These deprecated features will be only available until boost 1.55, that is you have 1 year and a half to move to the new features.
* Time related functions don't using the Boost.Chrono library, use the chrono overloads instead.
Breaking changes when BOOST_THREAD_VERSION==3:
There are some new features which share the same interface but with different behavior. These breaking features are provided by default when BOOST_THREAD_VERSION is 3, but the user can however choose the version 2 behavior by defining the corresponding macro. As for the deprecated features, these broken features will be only available until boost 1.55.
* [@http://svn.boost.org/trac/boost/ticket/6229 #6229] Rename the unique_future to future following the c++11.
* [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable.
* [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable.
Fixed Bugs:
* [@http://svn.boost.org/trac/boost/ticket/4258 #4258] Linking with boost thread does not work on mingw/gcc 4.5.
* [@http://svn.boost.org/trac/boost/ticket/4885 #4885] Access violation in set_tss_data at process exit due to invalid assumption about TlsAlloc.
* [@http://svn.boost.org/trac/boost/ticket/6931 #6931] mutex waits forwever with Intel Compiler and /debug:parallel
* [@http://svn.boost.org/trac/boost/ticket/7044 #7044] boost 1.50.0 header missing.
* [@http://svn.boost.org/trac/boost/ticket/7052 #7052] Thread: BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 only masks thread::operator==, thread::operator!= forward declarations, not definitions.
* [@http://svn.boost.org/trac/boost/ticket/7066 #7066] An attempt to fix current_thread_tls_key static initialization order.
* [@http://svn.boost.org/trac/boost/ticket/7074 #7074] Multiply defined symbol boost::allocator_arg.
* [@http://svn.boost.org/trac/boost/ticket/7078 #7078] Trivial 64-bit warning fix on Windows for thread attribute stack size
* [@http://svn.boost.org/trac/boost/ticket/7089 #7089] BOOST_THREAD_WAIT_BUG limits functionality without solving anything
[/
#6787 boost::thread::sleep() hangs if system time is rolled back
#7045 Thread library does not automatically compile date_time
]
[heading Version 3.0.0 - boost 1.50]
Breaking changes when BOOST_THREAD_VERSION==3:
* [@http://svn.boost.org/trac/boost/ticket/6229 #6229] Breaking change: Rename the unique_future to future following the c++11.
* [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable.
* [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable.
New Features:
* [@http://svn.boost.org/trac/boost/ticket/1850 #1850] Request for unlock_guard to compliment lock_guard.
* [@http://svn.boost.org/trac/boost/ticket/2637 #2637] Request for shared_mutex duration timed_lock and timed_lock_shared.
* [@http://svn.boost.org/trac/boost/ticket/2741 #2741] Proposal to manage portable and non portable thread attributes.
* [@http://svn.boost.org/trac/boost/ticket/3567 #3567] Request for shared_lock_guard.
* [@http://svn.boost.org/trac/boost/ticket/6194 #6194] Adapt to Boost.Move.
* [@http://svn.boost.org/trac/boost/ticket/6195 #6195] c++11 compliance: Provide the standard time related interface using Boost.Chrono.
* [@http://svn.boost.org/trac/boost/ticket/6217 #6217] Enhance Boost.Thread shared mutex interface following Howard Hinnant proposal.
* [@http://svn.boost.org/trac/boost/ticket/6224 #6224] c++11 compliance: Add the use of standard noexcept on compilers supporting them.
* [@http://svn.boost.org/trac/boost/ticket/6225 #6225] Add the use of standard =delete defaulted operations on compilers supporting them.
* [@http://svn.boost.org/trac/boost/ticket/6226 #6226] c++11 compliance: Add explicit bool conversion from locks.
* [@http://svn.boost.org/trac/boost/ticket/6228 #6228] Add promise constructor with allocator following the standard c++11.
* [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11.
* [@http://svn.boost.org/trac/boost/ticket/6231 #6231] Add BasicLockable requirements in the documentation to follow c++11.
* [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization.
* [@http://svn.boost.org/trac/boost/ticket/6273 #6273] c++11 compliance: Add cv_status enum class and use it on the conditions wait functions.
* [@http://svn.boost.org/trac/boost/ticket/6342 #6342] c++11 compliance: Adapt the one_flag to the c++11 interface.
* [@http://svn.boost.org/trac/boost/ticket/6671 #6671] upgrade_lock: missing mutex and release functions.
* [@http://svn.boost.org/trac/boost/ticket/6672 #6672] upgrade_lock:: missing constructors from time related types.
* [@http://svn.boost.org/trac/boost/ticket/6675 #6675] upgrade_lock:: missing non-member swap.
* [@http://svn.boost.org/trac/boost/ticket/6676 #6676] lock conversion should be explicit.
* Added missing packaged_task::result_type and packaged_task:: constructor with allocator.
* Added packaged_task::reset()
Fixed Bugs:
* [@http://svn.boost.org/trac/boost/ticket/2380 #2380] boost::move from lvalue does not work with gcc.
* [@http://svn.boost.org/trac/boost/ticket/2430 #2430] shared_mutex for win32 doesn't have timed_lock_upgrade.
* [@http://svn.boost.org/trac/boost/ticket/2575 #2575] Bug- Boost 1.36.0 on Itanium platform.
* [@http://svn.boost.org/trac/boost/ticket/3160 #3160] Duplicate tutorial code in boost::thread.
* [@http://svn.boost.org/trac/boost/ticket/4345 #4345] thread::id and joining problem with cascade of threads.
* [@http://svn.boost.org/trac/boost/ticket/4521 #4521] Error using boost::move on packaged_task (MSVC 10).
* [@http://svn.boost.org/trac/boost/ticket/4711 #4711] Must use implementation details to return move-only types.
* [@http://svn.boost.org/trac/boost/ticket/4921 #4921] BOOST_THREAD_USE_DLL and BOOST_THREAD_USE_LIB are crucial and need to be documented.
* [@http://svn.boost.org/trac/boost/ticket/5013 #5013] documentation: boost::thread: pthreas_exit causes terminate().
* [@http://svn.boost.org/trac/boost/ticket/5173 #5173] boost::this_thread::get_id is very slow.
* [@http://svn.boost.org/trac/boost/ticket/5351 #5351] interrupt a future get boost::unknown_exception.
* [@http://svn.boost.org/trac/boost/ticket/5516 #5516] Upgrade lock is not acquired when previous upgrade lock releases if another read lock is present.
* [@http://svn.boost.org/trac/boost/ticket/5990 #5990] shared_future<T>::get() has wrong return type.
* [@http://svn.boost.org/trac/boost/ticket/6174 #6174] packaged_task doesn't correctly handle moving results.
* [@http://svn.boost.org/trac/boost/ticket/6222 #6222] Compile error with SunStudio: unique_future move.
* [@http://svn.boost.org/trac/boost/ticket/6354 #6354] PGI: Compiler threading support is not turned on.
* [@http://svn.boost.org/trac/boost/ticket/6673 #6673] shared_lock: move assign doesn't works with c++11.
* [@http://svn.boost.org/trac/boost/ticket/6674 #6674] shared_mutex: try_lock_upgrade_until doesn't works.
* [@http://svn.boost.org/trac/boost/ticket/6908 #6908] Compile error due to unprotected definitions of _WIN32_WINNT and WINVER.
* [@http://svn.boost.org/trac/boost/ticket/6940 #6940] TIME_UTC is a macro in C11.
* [@http://svn.boost.org/trac/boost/ticket/6959 #6959] call of abs is ambiguous.
* Fix issue signaled on the ML with task_object(task_object const&) in presence of task_object(task_object &&)
[heading Version 2.1.1 - boost 1.49]
Fixed Bugs:
* [@http://svn.boost.org/trac/boost/ticket/2309 #2309] Lack of g++ symbol visibility support in Boost.Thread.
* [@http://svn.boost.org/trac/boost/ticket/2639 #2639] documentation should be extended(defer_lock, try_to_lock, ...).
* [@http://svn.boost.org/trac/boost/ticket/3639 #3639] Boost.Thread doesn't build with Sun-5.9 on Linux.
* [@http://svn.boost.org/trac/boost/ticket/3762 #3762] Thread can't be compiled with winscw (Codewarrior by Nokia).
* [@http://svn.boost.org/trac/boost/ticket/3885 #3885] document about mix usage of boost.thread and native thread api.
* [@http://svn.boost.org/trac/boost/ticket/3975 #3975] Incorrect precondition for promise::set_wait_callback().
* [@http://svn.boost.org/trac/boost/ticket/4048 #4048] thread::id formatting involves locale
* [@http://svn.boost.org/trac/boost/ticket/4315 #4315] gcc 4.4 Warning: inline ... declared as dllimport: attribute ignored.
* [@http://svn.boost.org/trac/boost/ticket/4480 #4480] OpenVMS patches for compiler issues workarounds.
* [@http://svn.boost.org/trac/boost/ticket/4819 #4819] boost.thread's documentation misprints.
* [@http://svn.boost.org/trac/boost/ticket/5423 #5423] thread issues with C++0x.
* [@http://svn.boost.org/trac/boost/ticket/5617 #5617] boost::thread::id copy ctor.
* [@http://svn.boost.org/trac/boost/ticket/5739 #5739] set-but-not-used warnings with gcc-4.6.
* [@http://svn.boost.org/trac/boost/ticket/5826 #5826] threads.cpp: resource leak on threads creation failure.
* [@http://svn.boost.org/trac/boost/ticket/5839 #5839] thread.cpp: ThreadProxy leaks on exceptions.
* [@http://svn.boost.org/trac/boost/ticket/5859 #5859] win32 shared_mutex constructor leaks on exceptions.
* [@http://svn.boost.org/trac/boost/ticket/6100 #6100] Compute hardware_concurrency() using get_nprocs() on GLIBC systems.
* [@http://svn.boost.org/trac/boost/ticket/6168 #6168] recursive_mutex is using wrong config symbol (possible typo).
* [@http://svn.boost.org/trac/boost/ticket/6175 #6175] Compile error with SunStudio.
* [@http://svn.boost.org/trac/boost/ticket/6200 #6200] patch to have condition_variable and mutex error better handle EINTR.
* [@http://svn.boost.org/trac/boost/ticket/6207 #6207] shared_lock swap compiler error on clang 3.0 c++11.
* [@http://svn.boost.org/trac/boost/ticket/6208 #6208] try_lock_wrapper swap compiler error on clang 3.0 c++11.
[heading Version 2.1.0 - Changes since boost 1.40]
The 1.41.0 release of Boost adds futures to the thread library. There are also a few minor changes.
@@ -25,7 +684,7 @@ The 1.36.0 release of Boost includes a few new features in the thread library:
* Backwards-compatibility overloads added for `timed_lock` and `timed_wait` functions to allow use of `xtime` for timeouts.
[heading Changes since boost 1.34]
[heading Version 2.0.0 - Changes since boost 1.34]
Almost every line of code in __boost_thread__ has been changed since the 1.34 release of boost. However, most of the interface
changes have been extensions, so the new code is largely backwards-compatible with the old code. The new features and breaking
@@ -85,3 +744,22 @@ been moved to __thread_id__.
unlocked one level, and not completely. This prior behaviour was not guaranteed and did not feature in the tests.
[endsect]
[section:future Future]
The following features will be included in next releases.
# Add some minor features, in particular
* [@http://svn.boost.org/trac/boost/ticket/7589 #7589] Synchro: Add polymorphic lockables.
# Add some features based on C++ proposals, in particular
* [@http://svn.boost.org/trac/boost/ticket/8273 #8273] Synchro: Add externally locked streams.
* [@http://svn.boost.org/trac/boost/ticket/8514 #8514] Async: Add a thread_pool executor with work stealing.
# And some additional extensions related to futures as:
* [@http://svn.boost.org/trac/boost/ticket/8517 #8517] Async: Add a variadic shared_future::then.
[endsect]

278
doc/compliance.qbk Normal file
View File

@@ -0,0 +1,278 @@
[/
(C) Copyright 2011-2015 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).
]
[section:compliance Conformance and Extension]
[////////////////////////////////////////////]
[section:cpp11 C++11 standard Thread library]
[///////////////////////////////////////////]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.html C++11 - Standard for Programming Language C++]]]
[table C++11 standard Conformance
[[Section] [Description] [Status] [Comments] [Ticket]]
[[30] [Thread support library] [Yes] [-] [-]]
[[30.1] [General] [-] [-] [-]]
[[30.2] [Requirements] [-] [-] [-]]
[[30.2.1] [Template parameter names] [-] [-] [-]]
[[30.2.2] [Exceptions] [Yes] [-] [-]]
[[30.2.3] [Native handles] [Yes] [-] [-]]
[[30.2.4] [Timing specifications] [Yes] [-] [-]]
[[30.2.5] [Requirements for Lockable types] [Yes] [-] [-]]
[[30.2.5.1] [In general] [-] [-] [-]]
[[30.2.5.2] [BasicLockable requirements] [Yes] [-] [-]]
[[30.2.5.3] [Lockable requirements] [yes] [-] [-]]
[[30.2.5.4] [TimedLockable requirements] [Yes] [-] [-]]
[[30.2.6] [decay_copy] [-] [-] [-]]
[[30.3] [Threads] [Yes] [-] [-]]
[[30.3.1] [Class thread] [Yes] [-] [-]]
[[30.3.1.1] [Class thread::id] [Yes] [-] [-]]
[[30.3.1.2] [thread constructors] [Partial] [-] [-]]
[[30.3.1.3] [thread destructor] [Yes] [-] [-]]
[[30.3.1.4] [thread assignment] [Yes] [-] [-]]
[[30.3.1.5] [thread members] [Yes] [-] [-]]
[[30.3.1.6] [thread static members] [Yes] [-] [-]]
[[30.3.1.7] [thread specialized algorithms] [Yes] [-] [-]]
[[30.3.2] [Namespace this_thread] [Yes] [-] [-]]
[[30.4] [Mutual exclusion] [Partial] [-] [-]]
[[30.4.1] [Mutex requirements] [Yes] [-] [-]]
[[30.4.1.1] [In general] [Yes] [-] [-]]
[[30.4.1.2] [Mutex types] [Yes] [-] [-]]
[[30.4.1.2.1] [Class mutex] [Yes] [-] [-]]
[[30.4.1.2.2] [Class recursive_mutex] [Yes] [-] [-]]
[[30.4.1.3] [Timed mutex types] [Yes] [-] [-]]
[[30.4.1.3.1] [Class timed_mutex] [Yes] [-] [-]]
[[30.4.1.3.1] [Class recursive_timed_mutex] [Yes] [-] [-]]
[[30.4.2] [Locks] [Yes] [-] [-]]
[[30.4.2.1] [Class template lock_guard] [Yes] [-] [-]]
[[30.4.2.2] [Class template unique_lock] [Yes] [-] [-]]
[[30.4.2.2.1] [unique_lock constructors, destructor, and assignment] [Yes] [-] [-]]
[[30.4.2.2.2] [unique_lock locking] [Yes] [-] [-]]
[[30.4.2.2.3] [unique_lock modifiers] [Yes] [-] [-]]
[[30.4.2.2.4] [unique_lock observers] [Yes] [ - ] [-]]
[[30.4.3] [Generic locking algorithms] [Partial] [variadic] [#6227]]
[[30.4.4] [Call once] [Yes] [-] [-]]
[[30.4.4.1] [Struct once_flag] [Yes] [-] [-]]
[[30.4.4.2] [Function call_once] [Yes] [-] [-]]
[[30.5] [Condition variables] [Yes] [-] [-]]
[[30.5.1] [Class condition_variable] [Yes] [-] [-]]
[[30.5.2] [Class condition_variable_any] [Yes] [-] [-]]
[[30.6] [Futures] [Yes] [-] [-]]
[[30.6.1] [Overview] [Partial] [-] [-]]
[[30.6.2] [Error handling] [Yes] [-] [-]]
[[30.6.3] [Class future_error] [-] [-] [-]]
[[30.6.4] [Shared state] [-] [-] [-]]
[[30.6.5] [Class template promise] [Yes] [-] [-]]
[[30.6.6] [Class template future] [Yes] [-] [-]]
[[30.6.7] [Class template shared_future] [Yes] [-] [-]]
[[30.6.8] [Function template async] [Yes] [-] [-]]
[[30.6.9] [Class template packaged_task] [Yes] [-] [-]]
]
[table Extension
[[Section] [Description] [Comments]]
[[30.3.1.5.x] [interrupt] [-]]
[[30.3.2.x] [Interruption] [-]]
[[30.3.2.y] [at_thread_exit] [-]]
[[30.4.3.x] [Generic locking algorithms begin/end] [-]]
]
[/
[[30.x] [Thread Local Storage] [-]]
[[30.y] [Class thread_group] [-]]
]
[endsect]
[section:cxx14 C++14 standard Thread library - accepted changes]
[//////////////////////////////////////////////////////////////]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.html Working Draft, Standard for Programming Language C++]]
[table [@http://isocpp.org/files/papers/N3659.html N3659 Shared locking in C++ revision 2] Conformance
[[Section] [Description] [Status] [Comments]]
[[30.4.1.4] [Shared Lockables Types] [Yes] [ - ]]
[[30.4.1.4.1] [shared_mutex class] [Yes] [ - ]]
[[30.4.2.3] [Class template shared_lock] [Yes] [-]]
]
[endsect]
[section:cxx1y C++14 TS Extensions for Concurrency V1 ]
[/////////////////////////////////////////////////////]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4107.html N4107-Extensions for Concurrency]]
[table Improvements to std::future<T> and related APIs]
[[Section] [Description] [Status] [Comments]]
[[2.1] [ - ] [ - ] [ - ]]
[[2.2] [Class template future] [Partial] [ - ]]
[[2.2] [then] [ Partial ] [ without implicit unwrapping #10550 and blocking #10551 ]]
[[2.2] [is_ready] [ Yes ] [ - ]]
[[2.3] [Class template shared_future] [Partial] [ - ]]
[[2.3] [then] [ Partial ] [ Without implicit unwrapping #10550 and blocking #10551 ]]
[[2.3] [is_ready] [ Yes ] [ - ]]
[[2.4] [Function template when_all] [Partial] [ interface not complete #10426 and blocking #10551 ]]
[[2.5] [Function template when_any] [Partial] [ interface not complete #10427 and blocking #10551 ]]
[[2.6] [Function template when_any_back] [No] [ #XXXX ]]
[[2.7] [Function template make_ready_future] [Yes] [ - ]]
]
[endsect]
[section:cxx1y C++1z TS Concurrency - On going proposals]
[///////////////////////////////////////////////////////]
[section:latch C++ Latches and Barriers]
[//////////////////////////////////////]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3600.html N3600 C++ Latches and Barriers]]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3817.html N3817 C++ Latches and Barriers]]
[table C++ Latches and Barriers Conformance
[[Section] [Description] [Status] [Comments]]
[[X.1] [Class latch] [Partial] [ A new class latch has been added. The interface is a super set of the one of the proposal, taking some of the functions of the class barrier.]]
[[X.2] [Class barrier] [No] [ Even if Boost.Thread has a class boost:barrier it doesn't provides the same kind of services. There is an experimental completion_latch that could be used instead. ]]
]
[endsect]
[section:queue C++ Concurrent Queues]
[///////////////////////////////////]
[note [@ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3533.html N3533 C++ Concurrent Queues]]
[table C++ Concurrent Queues Conformance
[[Section] [Description] [Status] [Comments]]
[[X.1] [Conceptual interface] [Partial] [ The interface provided has some differences respect to this proposal. All the functions having a queue_op_status are not provided. No lock-free concrete classes ]]
[[X.1.1] [Basic Operations] [Partial] [ - ]]
[[X.1.1.1] [push] [yes] [ renamed push_back. ]]
[[X.1.1.2] [value_pop] [no] [ renamed pull_front with two flavors. ]]
[[X.1.2] [Non-waiting operations] [ - ] [ - ]]
[[X.1.2.1] [try_push] [yes] [ renamed try_push_back ]]
[[X.1.2.2] [try_pop] [yes] [ renamed try_pull_back ]]
[[X.1.3] [Non-blocking operations] [ - ] [ - ]]
[[X.1.3.1] [nonblocking_push] [Yes] [ renamed nonblocking_push_back ]]
[[X.1.3.2] [nonblocking_pop] [Yes] [ renamed nonblocking_pull_front ]]
[[X.1.4] [Push-front operations] [No] [ - ]]
[[X.1.5] [Closed queues] [Partial] [ - ]]
[[X.1.5.1] [close] [Yes] [ - ]]
[[X.1.5.2] [is_closed] [Yes] [ renamed closed ]]
[[X.1.5.3] [wait_push] [Yes] [ renamed wait_push_back ]]
[[X.1.5.4] [wait_pop] [Yes] [ renamed wait_pull_front ]]
[[X.1.5.5] [wait_push_front] [no] [ - ]]
[[X.1.5.6] [wait_pop_back] [no] [ - ]]
[[X.1.5.6] [open] [no] [ - ]]
[[X.1.6] [Empty and Full Queues] [Yes] [ - ]]
[[X.1.6.1] [is_empty] [Yes] [ - ]]
[[X.1.6.2] [is_full] [Yes] [ Added capacity ]]
[[X.1.7] [Queue Names] [No] [ Not considered a must for the time been. ]]
[[X.1.8] [Element Type Requirements] [Yes?] [ - ]]
[[X.1.9] [Exception Handling] [Yes?] [ - ]]
[[X.1.10] [Queue Ordering] [Yes?] [ - ]]
[[X.1.11] [Lock-Free Implementations] [No] [ waiting to stabilize the lock-based interface. Will use Boost.LockFree once it is Boost.Move aware. ]]
[[X.2] [Concrete queues] [Partial] [ - ]]
[[X.2.1] [Locking Buffer Queue] [Partial] [ classes sync_queue and a sync_bounded_queue. ]]
[[X.2.1] [Lock-Free Buffer Queue] [No] [ waiting to stabilize the lock-based interface. Will use Boost.LockFree once it is Boost.Move aware. ]]
[[X.3] [Additional Conceptual Tools] [No] [ - ]]
[[X.3.1] [Fronts and Backs] [No] [ - ]]
[[X.3.2] [Streaming Iterators] [No] [ - ]]
[[X.3.3] [Storage Iterators] [No] [ - ]]
[[X.3.4] [Binary Interfaces] [No] [ - ]]
[[X.3.4] [Managed Indirection] [No] [ - ]]
]
[endsect]
[section:executors Executors and Schedulers]
[//////////////////////////////////////////]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3785.pdf N3785 Executors and Schedulers]]
[table Executors and Schedulers
[[Section] [Description] [Status] [Comments]]
[[V.1.1] [Class `executor`] [Yes] [ - ]]
[[V.1.1] [`add`] [Yes] [ renamed with a function template `submit` ]]
[[V.1.1] [`num_of_pendin_closures`] [No] [ ]]
[[V.1.2] [Class sceduled_executor] [No] [ - ]]
[[V.1.2] [`add_at`] [No] [ renamed with a function template `scheduler::submit_at` ]]
[[V.1.2] [`add_after`] [No] [ renamed with a function template `scheduler::submit_after` ]]
[[V.2] [Concrete executor classes] [No] [ - ]]
[[V.2.1] [`thread_pool`] [Yes] [ static version `basic_thread_pool`, dynamic one `execduler_adaptor<basic_thread_pool>` ]]
[[V.2.2] [`serial_executor`] [yes] [ - ]]
[[V.2.3] [`loop_executor`] [Yes] [ static version loop_scheduler, dynamic one `execduler_adaptor<loop_scheduler>` ]]
[[V.2.4] [`inline_executor`] [Yes] [ static version `inline_executor`, dynamic one `execduler_adaptor<inline_executor>` ]]
[[V.2.5] [`thread_executor`] [Yes] [ static version `thread_executor`, dynamic one `execduler_adaptor<thread_executor>` ]]
]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3784.pdf N3784-Improvements to `std::future<T> and Related APIs]]
[table `async, future/shared_future::then`and Executors
[[Section] [Description] [Status] [Comments]]
[[30.6.6] [`future<T>::then`] [Yes] [ ]]
[[30.6.7] [`shared_future<T>::then`] [Yes] [ ]]
[[30.6.8] [`async`] [Yes] [ - ]]
]
[note [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4143.pdf N4143-Executors and schedulers, revision 4]]
[table Executors and Schedulers - revision 4
[[Section] [Description] [Status] [Comments]]
[[VI.A] [Executor Concept] [Yes] [ `wrapper_type` renamed by `work` and `spawn by `submit` ]]
[[VI.A.1] [`thread_per_task_executor] [Yes] [ renamed `thread_executor`]]
[[VI.A.2] [`thread_pool_executor`] [Yes] [ renamed `basic_thread_pool`]]
[[VI.A.3] [`system_executor`] [No] [ - ]]
[[VI.A.4] [`loop_executor`] [Yes] [ - ]]
[[VI.A.5] [`serial_executor`] [yes] [ - ]]
[[VI.B] [`executor_ref`] [yes] [ - ]]
[[VI.C] [`executor`] [yes] [ renamed `gen_executor_ref` ]]
[[VI.D] [Free Functions and Helper Objects] [partial] [ - ]]
[[VI.D] [`make_package`] [No] [ - ]]
[[VI.D] [`spawn_future`] [No] [ `async(Ex&, ...)` is similar but returns a blocking future. ]]
[[VI.D] [`spawn`] [No] [ - ]]
[[VI.D] [`task_wrapper`] [No] [ renamed `resubmitter` ]]
[[VI.D] [`set_executor`] [No] [ renamed `resubmit` ]]
[[VI.D] [`function_wrapper`] [Partial] [ renamed `work` ]]
]
[endsect]
[//////////////////////////////////////////////////////////////
[section:stream_mutex C++ Stream Mutexes - C++ Stream Guards]
[/////////////////////////////////////////////////////////////]
While Boost.Thread implementation of stream mutexes differ in the approach, it is worth comparing with the current trend on the standard.
[note These functions are based on [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3535.html [*N3535 - C++ Stream Mutexes]] by Lawrence Crowl.]
[note This proposal has been replaced already by [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3678.html N3678 - C++ Stream Guards], which has been replaced by [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3678.html N3665 - Uninterleaved String Output Streaming] and [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3678.html N3750 - C++ Ostream Buffers]]
[table C++ Stream Mutexes Conformance
[[Section] [Description] [Status] [Comments]]
[[X.1] [Class template stream_mutex] [Partial] [ Renamed externally_locked_stream<> ]]
[[X.2.1] [constructor] [Partial] [ externally_locked_stream needs a mutex in addition as argument. ]]
[[X.2.2] [lock] [yes] [ - ]]
[[X.2.3] [unlock] [yes] [ - ]]
[[X.2.4] [try_lock] [yes] [ - ]]
[[X.2.5] [hold] [Yes] [ - ]]
[[X.2.6] [bypass] [Yes] [ - ]]
[[X.2] [Class template stream_guard] [Yes] [ - ]]
[[X.2.1] [stream_guard] [Yes] [ - ]]
[[X.2.2] [~stream_guard] [Yes] [ - ]]
[[X.2.3] [bypass] [Yes] [ - ]]
[[X.3] [Stream Operators] [Yes] [-]]
[[X.4] [Predefined Objects] [No] [-]]
]
[endsect]
///////////////////////////////]
[endsect]
[endsect]

View File

@@ -1,5 +1,6 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2007-11 Anthony Williams.
(C) Copyright 2011-12 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).
@@ -9,6 +10,18 @@
[heading Synopsis]
namespace boost
{
enum class cv_status;
{
no_timeout,
timeout
};
class condition_variable;
class condition_variable_any;
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
}
The classes `condition_variable` and `condition_variable_any` provide a
mechanism for one thread to wait for notification from another thread that a
particular condition has become true. The general usage pattern is that one
@@ -74,7 +87,7 @@ optimizations in some cases, based on the knowledge of the mutex type;
[section:condition_variable Class `condition_variable`]
#include <boost/thread/condition_variable.hpp>
//#include <boost/thread/condition_variable.hpp>
namespace boost
{
@@ -84,31 +97,54 @@ optimizations in some cases, based on the knowledge of the mutex type;
condition_variable();
~condition_variable();
void notify_one();
void notify_all();
void notify_one() noexcept;
void notify_all() noexcept;
void wait(boost::unique_lock<boost::mutex>& lock);
template<typename predicate_type>
void wait(boost::unique_lock<boost::mutex>& lock,predicate_type predicate);
bool timed_wait(boost::unique_lock<boost::mutex>& lock,boost::system_time const& abs_time);
template <class Clock, class Duration>
typename cv_status::type
wait_until(
unique_lock<mutex>& lock,
const chrono::time_point<Clock, Duration>& t);
template <class Clock, class Duration, class Predicate>
bool
wait_until(
unique_lock<mutex>& lock,
const chrono::time_point<Clock, Duration>& t,
Predicate pred);
template <class Rep, class Period>
typename cv_status::type
wait_for(
unique_lock<mutex>& lock,
const chrono::duration<Rep, Period>& d);
template <class Rep, class Period, class Predicate>
bool
wait_for(
unique_lock<mutex>& lock,
const chrono::duration<Rep, Period>& d,
Predicate pred);
#if defined BOOST_THREAD_USES_DATETIME
bool timed_wait(boost::unique_lock<boost::mutex>& lock,boost::system_time const& abs_time);
template<typename duration_type>
bool timed_wait(boost::unique_lock<boost::mutex>& lock,duration_type const& rel_time);
template<typename predicate_type>
bool timed_wait(boost::unique_lock<boost::mutex>& lock,boost::system_time const& abs_time,predicate_type predicate);
template<typename duration_type,typename predicate_type>
bool timed_wait(boost::unique_lock<boost::mutex>& lock,duration_type const& rel_time,predicate_type predicate);
// backwards compatibility
bool timed_wait(boost::unique_lock<boost::mutex>& lock,boost::xtime const& abs_time);
template<typename predicate_type>
bool timed_wait(boost::unique_lock<boost::mutex>& lock,boost::xtime const& abs_time,predicate_type predicate);
#endif
};
}
@@ -292,11 +328,112 @@ return true;
[endsect]
[section:wait_until `template <class Clock, class Duration> cv_status wait_until(boost::unique_lock<boost::mutex>& lock, const chrono::time_point<Clock, Duration>& abs_time)`]
[variablelist
[[Precondition:] [`lock` is locked by the current thread, and either no other
thread is currently waiting on `*this`, or the execution of the `mutex()` member
function on the `lock` objects supplied in the calls to `wait` or `wait_for` or `wait_until`
in all the threads currently waiting on `*this` would return the same value as
`lock->mutex()` for this call to `wait`.]]
[[Effects:] [Atomically call `lock.unlock()` and blocks the current thread. The
thread will unblock when notified by a call to `this->notify_one()` or
`this->notify_all()`, when the time as reported by `Clock::now()`
would be equal to or later than the specified `abs_time`, or spuriously. When
the thread is unblocked (for whatever reason), the lock is reacquired by
invoking `lock.lock()` before the call to `wait` returns. The lock is also
reacquired by invoking `lock.lock()` if the function exits with an exception.]]
[[Returns:] [`cv_status::timeout` if the call is returning because the time specified by
`abs_time` was reached, `cv_status::no_timeout` otherwise.]]
[[Postcondition:] [`lock` is locked by the current thread.]]
[[Throws:] [__thread_resource_error__ if an error
occurs. __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.]]
]
[endsect]
[section:wait_for `template <class Rep, class Period> cv_status wait_for(boost::unique_lock<boost::mutex>& lock, const chrono::duration<Rep, Period>& rel_time)`]
[variablelist
[[Precondition:] [`lock` is locked by the current thread, and either no other
thread is currently waiting on `*this`, or the execution of the `mutex()` member
function on the `lock` objects supplied in the calls to `wait` or `wait_until` or `wait_for`
in all the threads currently waiting on `*this` would return the same value as
`lock->mutex()` for this call to `wait`.]]
[[Effects:] [Atomically call `lock.unlock()` and blocks the current thread. The
thread will unblock when notified by a call to `this->notify_one()` or
`this->notify_all()`, after the period of time indicated by the `rel_time`
argument has elapsed, or spuriously. When the thread is unblocked (for whatever
reason), the lock is reacquired by invoking `lock.lock()` before the call to
`wait` returns. The lock is also reacquired by invoking `lock.lock()` if the
function exits with an exception.]]
[[Returns:] [`cv_status::timeout ` if the call is returning because the time period specified
by `rel_time` has elapsed, `cv_status::no_timeout ` otherwise.]]
[[Postcondition:] [`lock` is locked by the current thread.]]
[[Throws:] [__thread_resource_error__ if an error
occurs. __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.]]
]
[note The duration overload of timed_wait is difficult to use correctly. The overload taking a predicate should be preferred in most cases.]
[endsect]
[section:wait_until_predicate `template <class Clock, class Duration, class Predicate> bool wait_until(boost::unique_lock<boost::mutex>& lock, const chrono::time_point<Clock, Duration>& abs_time, Predicate pred)`]
[variablelist
[[Effects:] [As-if ``
while(!pred())
{
if(!wait_until(lock,abs_time))
{
return pred();
}
}
return true;
``]]
]
[endsect]
[section:wait_for_predicate `template <class Rep, class Period, class Predicate> bool wait_for(boost::unique_lock<boost::mutex>& lock, const chrono::duration<Rep, Period>& rel_time, Predicate pred)`]
[variablelist
[[Effects:] [As-if ``
return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred));
``]]
]
[endsect]
[endsect]
[section:condition_variable_any Class `condition_variable_any`]
#include <boost/thread/condition_variable.hpp>
//#include <boost/thread/condition_variable.hpp>
namespace boost
{
@@ -315,25 +452,43 @@ return true;
template<typename lock_type,typename predicate_type>
void wait(lock_type& lock,predicate_type predicate);
template <class lock_type, class Clock, class Duration>
cv_status wait_until(
lock_type& lock,
const chrono::time_point<Clock, Duration>& t);
template <class lock_type, class Clock, class Duration, class Predicate>
bool wait_until(
lock_type& lock,
const chrono::time_point<Clock, Duration>& t,
Predicate pred);
template <class lock_type, class Rep, class Period>
cv_status wait_for(
lock_type& lock,
const chrono::duration<Rep, Period>& d);
template <class lock_type, class Rep, class Period, class Predicate>
bool wait_for(
lock_type& lock,
const chrono::duration<Rep, Period>& d,
Predicate pred);
#if defined BOOST_THREAD_USES_DATETIME
template<typename lock_type>
bool timed_wait(lock_type& lock,boost::system_time const& abs_time);
template<typename lock_type,typename duration_type>
bool timed_wait(lock_type& lock,duration_type const& rel_time);
template<typename lock_type,typename predicate_type>
bool timed_wait(lock_type& lock,boost::system_time const& abs_time,predicate_type predicate);
template<typename lock_type,typename duration_type,typename predicate_type>
bool timed_wait(lock_type& lock,duration_type const& rel_time,predicate_type predicate);
// backwards compatibility
template<typename lock_type>
bool timed_wait(lock_type>& lock,boost::xtime const& abs_time);
template<typename lock_type,typename predicate_type>
bool timed_wait(lock_type& lock,boost::xtime const& abs_time,predicate_type predicate);
#endif
};
}
@@ -498,16 +653,138 @@ return true;
[endsect]
[section:wait_until `template <class lock_type, class Clock, class Duration> cv_status wait_until(lock_type& lock, const chrono::time_point<Clock, Duration>& abs_time)`]
[variablelist
[[Effects:] [Atomically call `lock.unlock()` and blocks the current thread. The
thread will unblock when notified by a call to `this->notify_one()` or
`this->notify_all()`, when the time as reported by `Clock::now()`
would be equal to or later than the specified `abs_time`, or spuriously. When
the thread is unblocked (for whatever reason), the lock is reacquired by
invoking `lock.lock()` before the call to `wait` returns. The lock is also
reacquired by invoking `lock.lock()` if the function exits with an exception.]]
[[Returns:] [`cv_status::timeout` if the call is returning because the time specified by
`abs_time` was reached, `cv_status::no_timeout` otherwise.]]
[[Postcondition:] [`lock` is locked by the current thread.]]
[[Throws:] [__thread_resource_error__ if an error
occurs. __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.]]
]
[endsect]
[section:condition Typedef `condition`]
[section:wait_for `template <class lock_type, class Rep, class Period> cv_status wait_for(lock_type& lock, const chrono::duration<Rep, Period>& rel_time)`]
#include <boost/thread/condition.hpp>
[variablelist
[[Effects:] [Atomically call `lock.unlock()` and blocks the current thread. The
thread will unblock when notified by a call to `this->notify_one()` or
`this->notify_all()`, after the period of time indicated by the `rel_time`
argument has elapsed, or spuriously. When the thread is unblocked (for whatever
reason), the lock is reacquired by invoking `lock.lock()` before the call to
`wait` returns. The lock is also reacquired by invoking `lock.lock()` if the
function exits with an exception.]]
[[Returns:] [`cv_status::timeout` if the call is returning because the time specified by
`abs_time` was reached, `cv_status::no_timeout` otherwise.]]
[[Postcondition:] [`lock` is locked by the current thread.]]
[[Throws:] [__thread_resource_error__ if an error
occurs. __thread_interrupted__ if the wait was interrupted by a call to
__interrupt__ on the __thread__ object associated with the current thread of execution.]]
]
[note The duration overload of timed_wait is difficult to use correctly. The overload taking a predicate should be preferred in most cases.]
[endsect]
[section:wait_until_predicate `template <class lock_type, class Clock, class Duration, class Predicate> bool wait_until(lock_type& lock, const chrono::time_point<Clock, Duration>& abs_time, Predicate pred)`]
[variablelist
[[Effects:] [As-if ``
while(!pred())
{
if(!__cvany_wait_until(lock,abs_time))
{
return pred();
}
}
return true;
``]]
]
[endsect]
[section:wait_for_predicate `template <class lock_type, class Rep, class Period, class Predicate> bool wait_for(lock_type& lock, const chrono::duration<Rep, Period>& rel_time, Predicate pred)`]
[variablelist
[[Effects:] [As-if ``
return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred));
``]]
]
[endsect]
[endsect]
[section:condition Typedef `condition` DEPRECATED V3]
// #include <boost/thread/condition.hpp>
namespace boost
{
typedef condition_variable_any condition;
}
The typedef `condition` is provided for backwards compatibility with previous boost releases.
[endsect]
[section:notify_all_at_thread_exit Non-member Function `notify_all_at_thread_exit`()]
// #include <boost/thread/condition_variable.hpp>
namespace boost
{
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
}
[variablelist
[[Requires:] [`lk` is locked by the calling thread and either no other thread is waiting on `cond`, or `lk.mutex()` returns the same value for each of the lock arguments supplied by all concurrently waiting (via `wait`, `wait_for`, or `wait_until`) threads.]]
[[Effects:] [transfers ownership of the lock associated with `lk` into internal storage and schedules `cond` to be notified when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed. This notification shall be as if
``
lk.unlock();
cond.notify_all();
``
]]
]
[/
[[Synchronization:] [The call to notify_all_at_thread_exit and the completion of the destructors for all the current threadÕs variables of thread storage duration synchronize with (1.10) calls to functions waiting on cond.
]]
[[Note:] [The supplied lock will be held until the thread exits, and care must be taken to ensure that this does not cause deadlock due to lock ordering issues. After calling notify_all_at_thread_exit it is recommended that the thread should be exited as soon as possible, and that no blocking or time-consuming tasks are run on that thread.
]]
[[Note:] [It is the userÕs responsibility to ensure that waiting threads do not erroneously assume that the thread has finished if they experience spurious wakeups. This typically requires that the condition being waited for is satisfied while holding the lock on lk, and that this lock is not released and reacquired prior to calling notify_all_at_thread_exit.
]]
]
[endsect]
[endsect]

416
doc/configuration.qbk Normal file
View File

@@ -0,0 +1,416 @@
[/
(C) Copyright 2012-2015 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).
]
[section:configuration Configuration]
[table Default Values for Configurable Features
[[Feature] [Anti-Feature] [V2] [V3] [V4] ]
[[USES_CHRONO] [DONT_USE_CHRONO] [YES/NO] [YES/NO] [YES/NO] ]
[[PROVIDES_INTERRUPTIONS] [DONT_PROVIDE_INTERRUPTIONS] [YES] [YES] [YES] ]
[[THROW_IF_PRECONDITION_NOT_SATISFIED] [-] [NO] [NO] [NO] ]
[[PROVIDES_PROMISE_LAZY] [DONT_PROVIDE_PROMISE_LAZY] [YES] [NO] [NO] ]
[[PROVIDES_BASIC_THREAD_ID] [DONT_PROVIDE_BASIC_THREAD_ID] [NO] [YES] [YES] ]
[[PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN] [DONT_PROVIDE_GENERIC_SHARED_MUTEX_ON_WIN] [NO] [YES] [YES] ]
[[PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION] [DONT_PROVIDE_SHARED_MUTEX_UPWARDS_CONVERSION] [NO] [YES] [YES] ]
[[PROVIDES_EXECUTORS] [-] [NO] [NO] [NO] ]
[[PROVIDES_EXPLICIT_LOCK_CONVERSION] [DONT_PROVIDE_EXPLICIT_LOCK_CONVERSION] [NO] [YES] [YES] ]
[[PROVIDES_FUTURE] [DONT_PROVIDE_FUTURE] [NO] [YES] [YES] ]
[[PROVIDES_FUTURE_CTOR_ALLOCATORS] [DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS] [NO] [YES] [YES] ]
[[PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE] [DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE] [NO] [YES] [YES] ]
[[PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE] [DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE] [NO] [YES] [YES] ]
[[PROVIDES_ONCE_CXX11] [DONT_PROVIDE_ONCE_CXX11] [NO] [YES] [YES] ]
[[USES_MOVE] [DONT_USE_MOVE] [NO] [YES] [YES] ]
[[USES_DATETIME] [DONT_USE_DATETIME] [YES/NO] [YES/NO] [YES/NO] ]
[[PROVIDES_THREAD_EQ] [DONT_PROVIDE_THREAD_EQ] [YES] [YES] [NO] ]
[[PROVIDES_CONDITION] [DONT_PROVIDE_CONDITION] [YES] [YES] [NO] ]
[[PROVIDES_NESTED_LOCKS] [DONT_PROVIDE_NESTED_LOCKS] [YES] [YES] [NO] ]
[[PROVIDES_SIGNATURE_PACKAGED_TASK] [DONT_PROVIDE_SIGNATURE_PACKAGED_TASK] [NO] [NO] [YES] ]
[[PROVIDES_FUTURE_INVALID_AFTER_GET] [DONT_PROVIDE_FUTURE_INVALID_AFTER_GET] [NO] [NO] [YES] ]
[/ [[PROVIDES_FUTURE_CONTINUATION] [DONT_PROVIDE_FUTURE_CONTINUATION] [NO] [NO] [YES] ] ]
[[PROVIDES_VARIADIC_THREAD] [DONT_PROVIDE_VARIADIC_THREAD] [NO] [NO] [C++11] ]
]
[section:chrono Boost.Chrono]
Boost.Thread uses by default Boost.Chrono for the time related functions and define `BOOST_THREAD_USES_CHRONO` if `BOOST_THREAD_DONT_USE_CHRONO` is not defined. The user should define `BOOST_THREAD_DONT_USE_CHRONO` for compilers that don't work well with Boost.Chrono.
[warning When defined BOOST_THREAD_PLATFORM_WIN32 BOOST_THREAD_USES_CHRONO is defined independently of user settings.]
[endsect]
[section:move Boost.Move]
Boost.Thread uses by default an internal move semantic implementation. Since version 3.0.0 you can use the move emulation emulation provided by Boost.Move.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_USES_MOVE ` if you want to use Boost.Move interface.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_USE_MOVE ` if you don't want to use Boost.Move interface.
[endsect]
[section:date_time Boost.DateTime]
The Boost.DateTime time related functions introduced in Boost 1.35.0, using the [link date_time Boost.Date_Time] library are deprecated. These include (but are not limited to):
* __sleep__
* __timed_join__
* __cond_timed_wait__
* __timed_lock_ref__
When `BOOST_THREAD_VERSION<=3` && defined BOOST_THREAD_PLATFORM_PTHREAD define `BOOST_THREAD_DONT_USE_DATETIME` if you don't want to use Boost.DateTime related interfaces.
When `BOOST_THREAD_VERSION>3` && defined BOOST_THREAD_PLATFORM_PTHREAD define `BOOST_THREAD_USES_DATETIME` if you want to use Boost.DateTime related interfaces.
[warning When defined BOOST_THREAD_PLATFORM_WIN32 BOOST_THREAD_USES_DATETIME is defined independently of user settings.]
[endsect]
[section:move Boost.Atomic]
Boost.Thread uses by default Boost.Atomic in POSIX platforms to implement call_once..
Define `BOOST_THREAD_USES_ATOMIC ` if you want to use Boost.Atomic.
Define `BOOST_THREAD_DONT_USE_ATOMIC ` if you don't want to use Boost.Atomic or if it is not supported in your platform.
[endsect]
[section:thread_eq `boost::thread::operator==` deprecated]
The following operators are deprecated:
* `boost::thread::operator==`
* `boost::thread::operator!=`
When `BOOST_THREAD_PROVIDES_THREAD_EQ` is defined Boost.Thread provides these deprecated feature.
Use instead
* `boost::thread::id::operator==`
* `boost::thread::id::operator!=`
[warning This is a breaking change respect to version 1.x.]
When `BOOST_THREAD_VERSION>=4` define `BOOST_THREAD_PROVIDES_THREAD_EQ ` if you want this feature.
When `BOOST_THREAD_VERSION<4` define `BOOST_THREAD_DONT_PROVIDE_THREAD_EQ ` if you don't want this feature.
[endsect]
[section:condition boost::condition deprecated]
`boost::condition` is deprecated. When `BOOST_THREAD_PROVIDES_CONDITION` is defined Boost.Thread provides this deprecated feature.
Use instead `boost::condition_variable_any`.
[warning This is a breaking change respect to version 1.x.]
When `BOOST_THREAD_VERSION>3` define `BOOST_THREAD_PROVIDES_CONDITION` if you want this feature.
When `BOOST_THREAD_VERSION<=3` define `BOOST_THREAD_DONT_PROVIDE_CONDITION` if you don't want this feature.
[endsect]
[section:nested_lock Mutex nested lock types deprecated]
The following nested typedefs are deprecated:
* `boost::mutex::scoped_lock`,
* `boost::mutex::scoped_try_lock`,
* `boost::timed_mutex::scoped_lock`
* `boost::timed_mutex::scoped_try_lock`
* `boost::timed_mutex::timed_scoped_timed_lock`
* `boost::recursive_mutex::scoped_lock`,
* `boost::recursive_mutex::scoped_try_lock`,
* `boost::recursive_timed_mutex::scoped_lock`
* `boost::recursive_timed_mutex::scoped_try_lock`
* `boost::recursive_timed_mutex::timed_scoped_timed_lock`
When `BOOST_THREAD_PROVIDES_NESTED_LOCKS` is defined Boost.Thread provides these deprecated feature.
Use instead
* `boost::unique_lock<boost::mutex>`,
* `boost::unique_lock<boost::mutex>` with the `try_to_lock_t` constructor,
* `boost::unique_lock<boost::timed_mutex>`
* `boost::unique_lock<boost::timed_mutex>` with the `try_to_lock_t` constructor
* `boost::unique_lock<boost::timed_mutex>`
* `boost::unique_lock<boost::recursive_mutex>`,
* `boost::unique_lock<boost::recursive_mutex>` with the `try_to_lock_t` constructor,
* `boost::unique_lock<boost::recursive_timed_mutex>`
* `boost::unique_lock<boost::recursive_timed_mutex>` with the `try_to_lock_t` constructor
* `boost::unique_lock<boost::recursive_timed_mutex>`
[warning This is a breaking change respect to version 1.x.]
When `BOOST_THREAD_VERSION>=4` define `BOOST_THREAD_PROVIDES_NESTED_LOCKS` if you want these features.
When `BOOST_THREAD_VERSION<4` define `BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS` if you don't want thes features.
[endsect]
[section:id thread::id]
Boost.Thread uses by default a thread::id on Posix based on the pthread type (BOOST_THREAD_PROVIDES_BASIC_THREAD_ID). For backward compatibility and also for compilers that don't work well with this modification the user can define `BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID`.
Define `BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID ` if you don't want these features.
[endsect]
[section:shared_gen Shared Locking Generic]
The shared mutex implementation on Windows platform provides currently less functionality than the generic one that is used for PTheads based platforms. In order to have access to these functions, the user needs to define `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` to use the generic implementation, that while could be less efficient, provides all the functions.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN ` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_GENERIC_SHARED_MUTEX_ON_WIN ` if you don't want these features.
[endsect]
[section:shared_upwards Shared Locking Upwards Conversion]
Boost.Threads includes in version 3 the Shared Locking Upwards Conversion as defined in [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking].
These conversions need to be used carefully to avoid deadlock or livelock. The user need to define explicitly `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` to get these upwards conversions.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION ` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_SHARED_MUTEX_UPWARDS_CONVERSION ` if you don't want these features.
[endsect]
[section:explicit_cnv Explicit Lock Conversion]
In [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking] the lock conversions are explicit. As this explicit conversion breaks the lock interfaces, it is provided only if the `BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION` is defined.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION ` if you want these features.
When `BOOST_THREAD_VERSION==3` define `BOOST_THREAD_DONT_PROVIDE_EXPLICIT_LOCK_CONVERSION ` if you don't want these features.
[endsect]
[section:future unique_future versus future]
C++11 uses `std::future`. Versions of Boost.Thread previous to version 3.0.0 uses `boost:unique_future`.
Since version 3.0.0 `boost::future` replaces `boost::unique_future` when `BOOST_THREAD_PROVIDES_FUTURE` is defined. The documentation doesn't contains anymore however `boost::unique_future`.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_FUTURE` if you want to use boost::future.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_FUTURE` if you want to use boost::unique_future.
[endsect]
[section:lazy promise lazy initialization]
C++11 promise initialize the associated state at construction time. Versions of Boost.Thread previous to version 3.0.0 initialize it lazily at any point in time in which this associated state is needed.
Since version 3.0.0 this difference in behavior can be configured. When `BOOST_THREAD_PROVIDES_PROMISE_LAZY` is defined the backward compatible behavior is provided.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_DONT_PROVIDE_PROMISE_LAZY ` if you want to use boost::future.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_PROVIDES_PROMISE_LAZY ` if you want to use boost::unique_future.
[endsect]
[section:alloc promise Allocator constructor]
C++11 std::promise provides constructors with allocators.
template <typename R>
class promise
{
public:
template <class Allocator>
explicit promise(allocator_arg_t, Allocator a);
// ...
};
template <class R, class Alloc> struct uses_allocator<promise<R>,Alloc>: true_type {};
where
struct allocator_arg_t { };
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
template <class T, class Alloc> struct uses_allocator;
Since version 3.0.0 Boost.Thread implements this constructor using the following interface
namespace boost
{
typedef container::allocator_arg_t allocator_arg_t;
constexpr allocator_arg_t allocator_arg = {};
namespace container
{
template <class R, class Alloc>
struct uses_allocator<promise<R>,Alloc>: true_type {};
}
template <class T, class Alloc>
struct uses_allocator : public container::uses_allocator<T, Alloc> {};
}
which introduces a dependency on Boost.Container. This feature is provided only if `BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS` is defined.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS ` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS ` if you don't want these features.
[endsect]
[section:terminate Call to terminate if joinable]
C++11 has a different semantic for the thread destructor and the move assignment. Instead of detaching the thread, calls to terminate() if the thread was joinable. When `BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE` and `BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE` is defined Boost.Thread provides the C++ semantic.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE ` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE ` if you don't want these features.
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE ` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE ` if you don't want these features.
[endsect]
[section:once_flag once_flag]
C++11 defines a default constructor for once_flag. When `BOOST_THREAD_PROVIDES_ONCE_CXX11 ` is defined Boost.Thread provides this C++ semantics. In this case, the previous aggregate syntax is not supported.
boost::once_flag once = BOOST_ONCE_INIT;
You should now just do
boost::once_flag once;
When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_ONCE_CXX11` if you want these features.
When `BOOST_THREAD_VERSION>=3` define `BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11` if you don't want these features.
[endsect]
[section:deprecated Signature parameter for packaged_task]
C++11 packaged task class has a Signature template parameter. When `BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK ` is defined Boost.Thread provides this C++ feature.
[warning This is a breaking change respect to version 3.x.]
When `BOOST_THREAD_VERSION<4` define `BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK` if you want this feature.
When `BOOST_THREAD_VERSION>=4` define `BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK` if you don't want this feature.
[endsect]
[section:thread_const-var thread constructor with variadic rvalue parameters]
C++11 thread constructor accep a variable number of rvalue argumentshas. When `BOOST_THREAD_PROVIDES_VARIADIC_THREAD ` is defined Boost.Thread provides this C++ feature if the following are not defined
* BOOST_NO_SFINAE_EXPR
* BOOST_NO_CXX11_VARIADIC_TEMPLATES
* BOOST_NO_CXX11_DECLTYPE
* BOOST_NO_CXX11_DECLTYPE_N3276
* BOOST_NO_CXX11_RVALUE_REFERENCES
* BOOST_NO_CXX11_TRAILING_RESULT_TYPES
* BOOST_NO_CXX11_RVALUE_REFERENCES
* BOOST_NO_CXX11_HDR_TUPLE
When `BOOST_THREAD_VERSION>4` define `BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD ` if you don't want this feature.
[endsect]
[section:get_invalid future<>::get() invalidates the future]
C++11 future<>::get() invalidates the future once its value has been obtained. When `BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET ` is defined Boost.Thread provides this C++ feature.
[warning This is a breaking change respect to version 3.x.]
When `BOOST_THREAD_VERSION<4` define `BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET` if you want this feature.
When `BOOST_THREAD_VERSION>=4` define `BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET` if you don't want this feature.
[endsect]
[section:intr Interruptions]
Thread interruption, while useful, makes any interruption point less efficient than if the thread were not interruptible.
When `BOOST_THREAD_PROVIDES_INTERRUPTIONS` is defined Boost.Thread provides interruptions.
When `BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS` is defined Boost.Thread don't provide interruption.
Boost.Thread defines BOOST_THREAD_PROVIDES_INTERRUPTIONS if neither BOOST_THREAD_PROVIDES_INTERRUPTIONS nor BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS are defined, so that there is no compatibility break.
[endsect]
[section:version Version]
`BOOST_THREAD_VERSION` defines the Boost.Thread version.
The default version is 2. In this case the following breaking or extending macros are defined if the opposite is not requested:
* `BOOST_THREAD_PROVIDES_PROMISE_LAZY`
The user can request the version 3 by defining `BOOST_THREAD_VERSION` to 3. In this case the following breaking or extending macros are defined if the opposite is not requested:
* Breaking change `BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION `
* Conformity & Breaking change `BOOST_THREAD_PROVIDES_FUTURE`
* Uniformity `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN`
* Extension `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION`
* Conformity `BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS`
* Conformity & Breaking change BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
* Conformity & Breaking change BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
* Conformity & Breaking change `BOOST_THREAD_PROVIDES_ONCE_CXX11`
* Breaking change `BOOST_THREAD_DONT_PROVIDE_PROMISE_LAZY`
[/The default value for `BOOST_THREAD_VERSION` will be changed to 3 since Boost 1.54.]
The user can request the version 4 by defining `BOOST_THREAD_VERSION` to 4. In this case the following breaking or extending macros are defined if the opposite is not requested:
* Conformity & Breaking change `BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK `
* Conformity & Breaking change `BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET `
* Conformity `BOOST_THREAD_PROVIDES_VARIADIC_THREAD`
* Breaking change `BOOST_THREAD_DONT_PROVIDE_THREAD_EQ`
* Breaking change `BOOST_THREAD_DONT_USE_DATETIME`
[/The default value for `BOOST_THREAD_VERSION` will be changed to 4 since Boost 1.58.]
[endsect]
[endsect]
[section:limitations Limitations]
Some compilers don't work correctly with some of the added features.
[section:sun SunPro]
If __SUNPRO_CC < 0x5100 the library defines
* `BOOST_THREAD_DONT_USE_MOVE`
If __SUNPRO_CC < 0x5100 the library defines
* `BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS`
[endsect]
[section:vacpp VACPP]
If __IBMCPP__ < 1100 the library defines
* `BOOST_THREAD_DONT_USE_CHRONO`
* `BOOST_THREAD_USES_DATE`
And Boost.Thread doesn't links with Boost.Chrono.
[endsect]
[section:ce WCE]
If _WIN32_WCE && _WIN32_WCE==0x501 the library defines
* `BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS`
[endsect]
[endsect]

365
doc/emulations.qbk Normal file
View File

@@ -0,0 +1,365 @@
[/
(C) Copyright 20012 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).
]
[section:emulations Emulations]
[section:delete `=delete` emulation]
C++11 allows to delete some implicitly generated functions as constructors and assignment using '= delete' as in
public:
thread(thread const&) = delete;
On compilers not supporting this feature, Boost.Thread relays on a partial simulation, it declares the function as private without definition.
private:
thread(thread &);
The emulation is partial as the private function can be used for overload resolution for some compilers and prefer it to other overloads that need a conversion. See below the consequences on the move semantic emulation.
[endsect]
[section:move Move semantics]
In order to implement Movable classes, move parameters and return types Boost.Thread uses the rvalue reference when the compiler support it.
On compilers not supporting it Boost.Thread uses either the emulation provided by Boost.Move or the emulation provided by the previous versions of Boost.Thread depending whether `BOOST_THREAD_USES_MOVE` is defined or not. This macros is unset by default when `BOOST_THREAD_VERSION` is 2. Since `BOOST_THREAD_VERSION` 3, `BOOST_THREAD_USES_MOVE` is defined.
[section:deprecated Deprecated Version 2 interface]
Previous to version 1.50, Boost.Thread make use of its own move semantic emulation which had more limitations than the provided by Boost.Move. In addition, it is of interest of the whole Boost community that Boost.Thread uses Boost.Move so that boost::thread can be stored on Movable aware containers.
To preserve backward compatibility at least during some releases, Boost.Thread allows the user to use the deprecated move semantic emulation defining BOOST_THREAD_DONT_USE_MOVE.
Many aspects of move semantics can be emulated for compilers not supporting rvalue references and Boost.Thread legacy offers tools for that purpose.
[section:Helper Helpers class and function]
Next follows the interface of the legacy move semantic helper class and function.
namespace boost
{
namespace detail
{
template<typename T>
struct thread_move_t
{
explicit thread_move_t(T& t_);
T& operator*() const;
T* operator->() const;
private:
void operator=(thread_move_t&);
};
}
template<typename T>
boost::detail::thread_move_t<T> move(boost::detail::thread_move_t<T> t);
}
[endsect]
[section:movable Movable emulation]
We can write a MovableOny class as follows. You just need to follow these simple steps:
* Add a conversion to the `detail::thread_move_t<classname>`
* Make the copy constructor private.
* Write a constructor taking the parameter as `detail::thread_move_t<classname>`
* Write an assignment taking the parameter as `detail::thread_move_t<classname>`
For example the thread class defines the following:
class thread
{
// ...
private:
thread(thread&);
thread& operator=(thread&);
public:
detail::thread_move_t<thread> move()
{
detail::thread_move_t<thread> x(*this);
return x;
}
operator detail::thread_move_t<thread>()
{
return move();
}
thread(detail::thread_move_t<thread> x)
{
thread_info=x->thread_info;
x->thread_info.reset();
}
thread& operator=(detail::thread_move_t<thread> x)
{
thread new_thread(x);
swap(new_thread);
return *this;
}
// ...
};
[endsect]
[endsect]
[section:portable Portable interface]
In order to make the library code portable Boost.Thread uses some macros that will use either the ones provided by Boost.Move or the deprecated move semantics provided by previous versions of Boost.Thread.
See the Boost.Move documentation for a complete description on how to declare new Movable classes and its limitations.
* `BOOST_THREAD_RV_REF(TYPE)` is the equivalent of `BOOST_RV_REF(TYPE)`
* `BOOST_THREAD_RV_REF_BEG` is the equivalent of `BOOST_RV_REF_BEG(TYPE)`
* `BOOST_THREAD_RV_REF_END` is the equivalent of `BOOST_RV_REF_END(TYPE)`
* `BOOST_THREAD_FWD_REF(TYPE)` is the equivalent of `BOOST_FWD_REF(TYPE)
In addition the following macros are needed to make the code portable:
* `BOOST_THREAD_RV(V)` macro to access the rvalue from a BOOST_THREAD_RV_REF(TYPE),
* `BOOST_THREAD_MAKE_RV_REF(RVALUE)` makes a rvalue.
* `BOOST_THREAD_DCL_MOVABLE(CLASS)` to avoid conflicts with Boost.Move
* `BOOST_THREAD_DCL_MOVABLE_BEG(T1)` and `BOOST_THREAD_DCL_MOVABLE_END` are variant of `BOOST_THREAD_DCL_MOVABLE` when the parameter is a template instantiation.
Other macros are provided and must be included on the public section:
* `BOOST_THREAD_NO_COPYABLE` declares a class no-copyable either deleting the copy constructors and copy assignment or moving them to the private section.
* `BOOST_THREAD_MOVABLE(CLASS)` declares all the implicit conversions to an rvalue-reference.
* `BOOST_THREAD_MOVABLE_ONLY(CLASS)` is the equivalent of `BOOST_MOVABLE_BUT_NOT_COPYABLE(CLASS)`
* `BOOST_THREAD_COPYABLE_AND_MOVABLE(CLASS)` is the equivalent of `BOOST_COPYABLE_AND_MOVABLE(CLASS)`
[section:NO_COPYABLE `BOOST_THREAD_NO_COPYABLE(CLASS)`]
This macro marks a class as no copyable, disabling copy construction and assignment.
[endsect]
[section:MOVABLE `BOOST_THREAD_MOVABLE(CLASS)`]
This macro marks a class as movable, declaring all the implicit conversions to an rvalue-reference.
[endsect]
[section:MOVABLE_ONLY `BOOST_THREAD_MOVABLE_ONLY(CLASS)`]
This macro marks a type as movable but not copyable, disabling copy construction and assignment. The user will need to write a move constructor/assignment to fully write a movable but not copyable class.
[endsect]
[section:COPYABLE_AND_MOVABLE `BOOST_THREAD_COPYABLE_AND_MOVABLE(CLASS)`]
This macro marks a type as copyable and movable. The user will need to write a move constructor/assignment and a copy assignment to fully write a copyable and movable class.
[endsect]
[section:RV_REF `BOOST_THREAD_RV_REF(TYPE)`, `BOOST_THREAD_RV_REF_BEG` and `BOOST_THREAD_RV_REF_END`]
This macro is used to achieve portable syntax in move constructors and assignments for classes marked as `BOOST_THREAD_COPYABLE_AND_MOVABLE` or `BOOST_THREAD_MOVABLE_ONLY`.
`BOOST_THREAD_RV_REF_BEG` and `BOOST_THREAD_RV_REF_END` are used when the parameter end with a `>` to avoid the compiler error.
[endsect]
[section:RV `BOOST_THREAD_RV(V)`]
While Boost.Move emulation allows to access an rvalue reference `BOOST_THREAD_RV_REF(TYPE)` using the dot operator, the legacy defines the `operator->`. We need then a macro `BOOST_THREAD_RV` that mask this difference. E.g.
thread(BOOST_THREAD_RV_REF(thread) x)
{
thread_info=BOOST_THREAD_RV(x).thread_info;
BOOST_THREAD_RV(x).thread_info.reset();
}
The use of this macros has reduced considerably the size of the Boost.Thread move related code.
[endsect]
[section:MAKE_RV_REF `BOOST_THREAD_MAKE_RV_REF(RVALUE)`]
While Boost.Move is the best C++03 move emulation there are some limitations that impact the way the library can be used.
For example, with the following declarations
class thread {
// ...
private:
thread(thread &);
public:
thread(rv<thread>&);
// ...
};
This could not work on some compilers even if thread is convertible to `rv<thread>` because the compiler prefers the private copy constructor.
thread mkth()
{
return thread(f);
}
On these compilers we need to use instead an explicit conversion. The library provides a move member function that allows to workaround the issue.
thread mkth()
{
return thread(f).move();
}
Note that `::boost::move` can not be used in this case as thread is not implicitly convertible to `thread&`.
thread mkth()
{
return ::boost::move(thread(f));
}
To make the code portable Boost.Thread the user needs to use a macro `BOOST_THREAD_MAKE_RV_REF` that can be used as in
thread mkth()
{
return BOOST_THREAD_MAKE_RV_REF(thread(f));
}
Note that this limitation is shared also by the legacy Boost.Thread move emulation.
[endsect]
[section:DCL_MOVABLE `BOOST_THREAD_DCL_MOVABLE`, `BOOST_THREAD_DCL_MOVABLE_BEG(T1)` and `BOOST_THREAD_DCL_MOVABLE_END`]
As Boost.Move defines also the `boost::move` function we need to specialize the `has_move_emulation_enabled_aux` metafunction.
template <>
struct has_move_emulation_enabled_aux<thread>
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
{};
so that the following Boost.Move overload is disabled
template <class T>
inline typename BOOST_MOVE_BOOST_NS::disable_if<has_move_emulation_enabled_aux<T>, T&>::type move(T& x);
The macros `BOOST_THREAD_DCL_MOVABLE(CLASS)`, `BOOST_THREAD_DCL_MOVABLE_BEG(T1)` and `BOOST_THREAD_DCL_MOVABLE_END` are used for this purpose. E.g.
BOOST_THREAD_DCL_MOVABLE(thread)
and
BOOST_THREAD_DCL_MOVABLE_BEG(T) promise<T> BOOST_THREAD_DCL_MOVABLE_END
[endsect]
[endsect]
[endsect]
[section:bool_explicit_conversion Bool explicit conversion]
Locks provide an explicit bool conversion operator when the compiler provides them.
explicit operator bool() const;
The library provides un implicit conversion to an undefined type that can be used as a conditional expression.
#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
operator ``['unspecified-bool-type]``() const;
bool operator!() const;
#else
explicit operator bool() const;
#endif
The user should use the lock.owns_lock() when an explicit conversion is required.
[section:bool_conversion `operator `['unspecified-bool-type]`() const`]
[variablelist
[[Returns:] [If __owns_lock_ref__ would return `true`, a value that evaluates to
`true` in boolean contexts, otherwise a value that evaluates to `false` in
boolean contexts.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:operator_not `bool operator!() const`]
[variablelist
[[Returns:] [`!` __owns_lock_ref__.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[section:scoped_enums Scoped Enums]
Some of the enumerations defined in the standard library are scoped enums.
On compilers that don't support them, the library uses a class to wrap the underlying type. Instead of
enum class future_errc
{
broken_promise,
future_already_retrieved,
promise_already_satisfied,
no_state
};
the library declare these types as
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc)
{
broken_promise,
future_already_retrieved,
promise_already_satisfied,
no_state
}
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
These macros allows to use 'future_errc' in almost all the cases as a scoped enum.
There are however some limitations:
* The type is not a C++ enum, so 'is_enum<future_errc>' will be false_type.
* The emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some macros.
Instead of
switch (ev)
{
case future_errc::broken_promise:
// ...
use
switch (boost::native_value(ev))
{
case future_errc::broken_promise:
And instead of
#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
template <>
struct BOOST_SYMBOL_VISIBLE is_error_code_enum<future_errc> : public true_type { };
#endif
use
#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
template <>
struct BOOST_SYMBOL_VISIBLE is_error_code_enum<future_errc::enum_type> : public true_type { };
#endif
[endsect]
[endsect]

592
doc/external_locking.qbk Normal file
View File

@@ -0,0 +1,592 @@
[/
/ Copyright (c) 2008,2012,2014 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)
/]
[section External Locking -- `strict_lock` and `externally_locked` classes]
[note This tutorial is an adaptation of the paper by Andrei Alexandrescu "Multithreading and the C++ Type System"
to the Boost library.]
[/
[section Internal locking]
Consider, for example, modeling a bank account class that supports simultaneous deposits and withdrawals from multiple locations (arguably the "Hello, World" of multi-threaded programming). In the code below, guard's constructor locks the passed-in object this, and guard's destructor unlocks this.
class BankAccount {
boost::mutex mtx_; // explicit mutex declaration
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ -= amount;
}
int GetBalance() {
boost::lock_guard<boost::mutex> guard(mtx_);
return balance_;
}
};
The object-level locking idiom doesn't cover the entire richness of a threading model. For example, the model above is quite deadlock-prone when you try to coordinate multi-object transactions. Nonetheless, object-level locking is useful in many cases, and in combination with other mechanisms can provide a satisfactory solution to many threaded access problems in object-oriented programs.
[endsect]
[section Internal and external locking]
The BankAccount class above uses internal locking. Basically, a class that uses internal locking guarantees that any concurrent calls to its public member functions don't corrupt an instance of that class. This is typically ensured by having each public member function acquire a lock on the object upon entry. This way, for any given object of that class, there can be only one member function call active at any moment, so the operations are nicely serialized.
This approach is reasonably easy to implement and has an attractive simplicity. Unfortunately, "simple" might sometimes morph into "simplistic."
Internal locking is insufficient for many real-world synchronization tasks. Imagine that you want to implement an ATM withdrawal transaction with the BankAccount class. The requirements are simple. The ATM transaction consists of two withdrawals-one for the actual money and one for the $2 commission. The two withdrawals must appear in strict sequence; that is, no other transaction can exist between them.
The obvious implementation is erratic:
void ATMWithdrawal(BankAccount& acct, int sum) {
acct.Withdraw(sum);
// preemption possible
acct.Withdraw(2);
}
The problem is that between the two calls above, another thread can perform another operation on the account, thus breaking the second design requirement.
In an attempt to solve this problem, let's lock the account from the outside during the two operations:
void ATMWithdrawal(BankAccount& acct, int sum) {
boost::lock_guard<boost::mutex> guard(acct.mtx_); // mtx_ field is private
acct.Withdraw(sum);
acct.Withdraw(2);
}
Notice that the code above doesn't compiles, the `mtx_` field is private.
We have two possibilities:
* make `mtx_` public which seams odd
* make the `BankAccount` lockable by adding the lock/unlock functions
We can add these functions explicitly
class BankAccount {
boost::mutex mtx_;
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ -= amount;
}
void lock() {
mtx_.lock();
}
void unlock() {
mtx_.unlock();
}
};
or inheriting from a class which add these lockable functions.
The `basic_lockable_adapter` class helps to define the `BankAccount` class as
class BankAccount
: public basic_lockable_adapter<boost::mutex>
{
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<BankAccount> guard(*this);
// boost::lock_guard<boost::mutex> guard(*this->mutex());
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<BankAccount> guard(*this);
// boost::lock_guard<boost::mutex> guard(*this->mutex());
balance_ -= amount;
}
int GetBalance() {
boost::lock_guard<BankAccount> guard(*this);
// boost::lock_guard<boost::mutex> guard(*this->mutex());
return balance_;
}
};
and the code that does not compiles becomes
void ATMWithdrawal(BankAccount& acct, int sum) {
// boost::lock_guard<boost::mutex> guard(*acct.mutex());
boost::lock_guard<BankAccount> guard(acct);
acct.Withdraw(sum);
acct.Withdraw(2);
}
Notice that now acct is being locked by Withdraw after it has already been locked by guard. When running such code, one of two things happens.
* Your mutex implementation might support the so-called recursive mutex semantics. This means that the same thread can lock the same mutex several times successfully. In this case, the implementation works but has a performance overhead due to unnecessary locking. (The locking/unlocking sequence in the two Withdraw calls is not needed but performed anyway-and that costs time.)
* Your mutex implementation might not support recursive locking, which means that as soon as you try to acquire it the second time, it blocks-so the ATMWithdrawal function enters the dreaded deadlock.
As `boost::mutex` is not recursive, we need to use its recursive version `boost::recursive_mutex`.
class BankAccount
: public basic_lockable_adapter<boost::recursive_mutex>
{
// ...
};
The caller-ensured locking approach is more flexible and the most efficient, but very dangerous. In an implementation using caller-ensured locking, BankAccount still holds a mutex, but its member functions don't manipulate it at all. Deposit and Withdraw are not thread-safe anymore. Instead, the client code is responsible for locking BankAccount properly.
class BankAccount
: public basic_lockable_adapter<boost::mutex> {
int balance_;
public:
void Deposit(int amount) {
balance_ += amount;
}
void Withdraw(int amount) {
balance_ -= amount;
}
};
Obviously, the caller-ensured locking approach has a safety problem. BankAccount's implementation code is finite, and easy to reach and maintain, but there's an unbounded amount of client code that manipulates BankAccount objects. In designing applications, it's important to differentiate between requirements imposed on bounded code and unbounded code. If your class makes undue requirements on unbounded code, that's usually a sign that encapsulation is out the window.
To conclude, if in designing a multi-threaded class you settle on internal locking, you expose yourself to inefficiency or deadlocks. On the other hand, if you rely on caller-provided locking, you make your class error-prone and difficult to use. Finally, external locking completely avoids the issue by leaving it all to the client code.
[endsect]
]
[section Locks as permits]
So what to do? Ideally, the BankAccount class should do the following:
* Support both locking models (internal and external).
* Be efficient; that is, use no unnecessary locking.
* Be safe; that is, BankAccount objects cannot be manipulated without appropriate locking.
Let's make a worthwhile observation: Whenever you lock a BankAccount, you do so by using a `lock_guard<BankAccount>` object. Turning this statement around, wherever there's a `lock_guard<BankAccount>`, there's also a locked `BankAccount` somewhere. Thus, you can think of-and use-a `lock_guard<BankAccount>` object as a permit. Owning a `lock_guard<BankAccount>` gives you rights to do certain things. The `lock_guard<BankAccount>` object should not be copied or aliased (it's not a transmissible permit).
# As long as a permit is still alive, the `BankAccount` object stays locked.
# When the `lock_guard<BankAccount>` is destroyed, the `BankAccount`'s mutex is released.
The net effect is that at any point in your code, having access to a `lock_guard<BankAccount>` object guarantees that a `BankAccount` is locked. (You don't know exactly which `BankAccount` is locked, however-an issue that we'll address soon.)
For now, let's make a couple of enhancements to the `lock_guard` class template defined in Boost.Thread.
We'll call the enhanced version `strict_lock`. Essentially, a `strict_lock`'s role is only to live on the stack as an automatic variable.
`strict_lock` must adhere to a non-copy and non-alias policy.
`strict_lock` disables copying by making the copy constructor and the assignment operator private.
[/
While we're at it, let's disable operator new and operator delete.
`strict_lock` are not intended to be allocated on the heap.
`strict_lock` avoids aliasing by using a slightly less orthodox and less well-known technique: disable address taking.
]
template <typename Lockable>
class strict_lock {
public:
typedef Lockable lockable_type;
explicit strict_lock(lockable_type& obj) : obj_(obj) {
obj.lock(); // locks on construction
}
strict_lock() = delete;
strict_lock(strict_lock const&) = delete;
strict_lock& operator=(strict_lock const&) = delete;
~strict_lock() { obj_.unlock(); } // unlocks on destruction
bool owns_lock(mutex_type const* l) const noexcept // strict lockers specific function
{
return l == &obj_;
}
private:
lockable_type& obj_;
};
Silence can be sometimes louder than words-what's forbidden to do with a `strict_lock` is as important as what you can do. Let's see what you can and what you cannot do with a `strict_lock` instantiation:
* You can create a `strict_lock<T>` only starting from a valid T object. Notice that there is no other way you can create a `strict_lock<T>`.
BankAccount myAccount("John Doe", "123-45-6789");
strict_lock<BankAccount> myLock(myAccount); // ok
* You cannot copy `strict_lock`s to one another. In particular, you cannot pass `strict_lock`s by value to functions or have them returned by functions:
extern strict_lock<BankAccount> Foo(); // compile-time error
extern void Bar(strict_lock<BankAccount>); // compile-time error
* However, you still can pass `strict_lock`s by reference to and from functions:
// ok, Foo returns a reference to strict_lock<BankAccount>
extern strict_lock<BankAccount>& Foo();
// ok, Bar takes a reference to strict_lock<BankAccount>
extern void Bar(strict_lock<BankAccount>&);
[/
* You cannot allocate a `strict_lock` on the heap. However, you still can put `strict_lock`s on the heap if they're members of a class.
strict_lock<BankAccount>* pL =
new strict_lock<BankAccount>(myAcount); //error!
// operator new is not accessible
class Wrapper {
strict_lock memberLock_;
...
};
Wrapper* pW = new Wrapper; // ok
(Making `strict_lock` a member variable of a class is not recommended. Fortunately, disabling copying and default construction makes `strict_lock` quite an unfriendly member variable.)
* You cannot take the address of a `strict_lock` object. This interesting feature, implemented by disabling unary operator&, makes it very unlikely to alias a `strict_lock` object. Aliasing is still possible by taking references to a `strict_lock`:
strict_lock<BankAccount> myLock(myAccount); // ok
strict_lock<BankAccount>* pAlias = &myLock; // error!
// strict_lock<BankAccount>::operator& is not accessible
strict_lock<BankAccount>& rAlias = myLock; // ok
Fortunately, references don't engender as bad aliasing as pointers because they're much less versatile (references cannot be copied or reseated).
]
[/* You can even make `strict_lock` final; that is, impossible to derive from. This task is left in the form of an exercise to the reader.
]
All these rules were put in place with one purpose-enforcing that owning a `strict_lock<T>` is a reasonably strong guarantee that
# you locked a T object, and
# that object will be unlocked at a later point.
Now that we have such a strict `strict_lock`, how do we harness its power in defining a safe, flexible interface for BankAccount? The idea is as follows:
* Each of BankAccount's interface functions (in our case, Deposit and Withdraw) comes in two overloaded variants.
* One version keeps the same signature as before, and the other takes an additional argument of type `strict_lock<BankAccount>`. The first version is internally locked; the second one requires external locking. External locking is enforced at compile time by requiring client code to create a `strict_lock<BankAccount>` object.
* BankAccount avoids code bloating by having the internal locked functions forward to the external locked functions, which do the actual job.
A little code is worth 1,000 words, a (hacked into) saying goes, so here's the new BankAccount class:
class BankAccount
: public basic_lockable_adapter<boost::mutex>
{
int balance_;
public:
void Deposit(int amount, strict_lock<BankAccount>&) {
// Externally locked
balance_ += amount;
}
void Deposit(int amount) {
strict_lock<BankAccount> guard(*this); // Internally locked
Deposit(amount, guard);
}
void Withdraw(int amount, strict_lock<BankAccount>&) {
// Externally locked
balance_ -= amount;
}
void Withdraw(int amount) {
strict_lock<BankAccount> guard(*this); // Internally locked
Withdraw(amount, guard);
}
};
Now, if you want the benefit of internal locking, you simply call `Deposit(int)` and `Withdraw(int)`. If you want to use external locking, you lock the object by constructing a `strict_lock<BankAccount>` and then you call `Deposit(int, strict_lock<BankAccount>&)` and `Withdraw(int, strict_lock<BankAccount>&)`. For example, here's the `ATMWithdrawal` function implemented correctly:
void ATMWithdrawal(BankAccount& acct, int sum) {
strict_lock<BankAccount> guard(acct);
acct.Withdraw(sum, guard);
acct.Withdraw(2, guard);
}
This function has the best of both worlds-it's reasonably safe and efficient at the same time.
It's worth noting that `strict_lock` being a template gives extra safety compared to a straight polymorphic approach. In such a design, BankAccount would derive from a Lockable interface. `strict_lock` would manipulate Lockable references so there's no need for templates. This approach is sound; however, it provides fewer compile-time guarantees. Having a `strict_lock` object would only tell that some object derived from Lockable is currently locked. In the templated approach, having a `strict_lock<BankAccount>` gives a stronger guarantee-it's a `BankAccount` that stays locked.
There's a weasel word in there-I mentioned that ATMWithdrawal is reasonably safe. It's not really safe because there's no enforcement that the `strict_lock<BankAccount>` object locks the appropriate BankAccount object. The type system only ensures that some BankAccount object is locked. For example, consider the following phony implementation of ATMWithdrawal:
void ATMWithdrawal(BankAccount& acct, int sum) {
BankAccount fakeAcct("John Doe", "123-45-6789");
strict_lock<BankAccount> guard(fakeAcct);
acct.Withdraw(sum, guard);
acct.Withdraw(2, guard);
}
This code compiles warning-free but obviously doesn't do the right thing-it locks one account and uses another.
It's important to understand what can be enforced within the realm of the C++ type system and what needs to be enforced at runtime. The mechanism we've put in place so far ensures that some BankAccount object is locked during the call to `BankAccount::Withdraw(int, strict_lock<BankAccount>&)`. We must enforce at runtime exactly what object is locked.
If our scheme still needs runtime checks, how is it useful? An unwary or malicious programmer can easily lock the wrong object and manipulate any BankAccount without actually locking it.
First, let's get the malice issue out of the way. C is a language that requires a lot of attention and discipline from the programmer. C++ made some progress by asking a little less of those, while still fundamentally trusting the programmer. These languages are not concerned with malice (as Java is, for example). After all, you can break any C/C++ design simply by using casts "appropriately" (if appropriately is an, er, appropriate word in this context).
The scheme is useful because the likelihood of a programmer forgetting about any locking whatsoever is much greater than the likelihood of a programmer who does remember about locking, but locks the wrong object.
Using `strict_lock` permits compile-time checking of the most common source of errors, and runtime checking of the less frequent problem.
Let's see how to enforce that the appropriate BankAccount object is locked. First, we need to add a member function to the `strict_lock` class template.
The `bool strict_lock<T>::owns_lock(Lockable*)` function returns a reference to the locked object.
template <class Lockable> class strict_lock {
... as before ...
public:
bool owns_lock(Lockable* mtx) const { return mtx==&obj_; }
};
Second, BankAccount needs to use this function compare the locked object against this:
class BankAccount {
: public basic_lockable_adapter<boost::mutex>
int balance_;
public:
void Deposit(int amount, strict_lock<BankAccount>& guard) {
// Externally locked
if (!guard.owns_lock(*this))
throw "Locking Error: Wrong Object Locked";
balance_ += amount;
}
// ...
};
The overhead incurred by the test above is much lower than locking a recursive mutex for the second time.
[endsect]
[section Improving External Locking]
Now let's assume that BankAccount doesn't use its own locking at all, and has only a thread-neutral implementation:
class BankAccount {
int balance_;
public:
void Deposit(int amount) {
balance_ += amount;
}
void Withdraw(int amount) {
balance_ -= amount;
}
};
Now you can use BankAccount in single-threaded and multi-threaded applications alike, but you need to provide your own synchronization in the latter case.
Say we have an AccountManager class that holds and manipulates a BankAccount object:
class AccountManager
: public basic_lockable_adapter<boost::mutex>
{
BankAccount checkingAcct_;
BankAccount savingsAcct_;
...
};
Let's also assume that, by design, AccountManager must stay locked while accessing its BankAccount members. The question is, how can we express this design constraint using the C++ type system? How can we state "You have access to this BankAccount object only after locking its parent AccountManager object"?
The solution is to use a little bridge template `externally_locked` that controls access to a BankAccount.
template <typename T, typename Lockable>
class externally_locked {
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
public:
externally_locked(T& obj, Lockable& lockable)
: obj_(obj)
, lockable_(lockable)
{}
externally_locked(Lockable& lockable)
: obj_()
, lockable_(lockable)
{}
T& get(strict_lock<Lockable>& lock) {
#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
if (!lock.owns_lock(&lockable_)) throw lock_error(); //run time check throw if not locks the same
#endif
return obj_;
}
void set(const T& obj, Lockable& lockable) {
obj_ = obj;
lockable_=lockable;
}
private:
T obj_;
Lockable& lockable_;
};
`externally_locked` cloaks an object of type T, and actually provides full access to that object through the get and set member functions, provided you pass a reference to a `strict_lock<Owner>` object.
Instead of making `checkingAcct_` and `savingsAcct_` of type `BankAccount`, `AccountManager` holds objects of type `externally_locked<BankAccount, AccountManager>`:
class AccountManager
: public basic_lockable_adapter<boost::mutex>
{
public:
typedef basic_lockable_adapter<boost::mutex> lockable_base_type;
AccountManager()
: checkingAcct_(*this)
, savingsAcct_(*this)
{}
inline void Checking2Savings(int amount);
inline void AMoreComplicatedChecking2Savings(int amount);
private:
externally_locked<BankAccount, AccountManager> checkingAcct_;
externally_locked<BankAccount, AccountManager> savingsAcct_;
};
The pattern is the same as before - to access the BankAccount object cloaked by `checkingAcct_`, you need to call `get`. To call `get`, you need to pass it a `strict_lock<AccountManager>`. The one thing you have to take care of is to not hold pointers or references you obtained by calling `get`. If you do that, make sure that you don't use them after the strict_lock has been destroyed. That is, if you alias the cloaked objects, you're back from "the compiler takes care of that" mode to "you must pay attention" mode.
Typically, you use `externally_locked` as shown below. Suppose you want to execute an atomic transfer from your checking account to your savings account:
void AccountManager::Checking2Savings(int amount) {
strict_lock<AccountManager> guard(*this);
checkingAcct_.get(guard).Withdraw(amount);
savingsAcct_.get(guard).Deposit(amount);
}
We achieved two important goals. First, the declaration of `checkingAcct_` and `savingsAcct_` makes it clear to the code reader that that variable is protected by a lock on an AccountManager. Second, the design makes it impossible to manipulate the two accounts without actually locking a BankAccount. `externally_locked` is what could be called active documentation.
[endsect]
[section Allowing other strict locks]
Now imagine that the AccountManager function needs to take a `unique_lock` in order to reduce the critical regions. And at some time it needs to access to the `checkingAcct_`. As `unique_lock` is not a strict lock the following code doesn't compile:
void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
unique_lock<AccountManager> guard(*this, defer_lock);
if (some_condition()) {
guard.lock();
}
checkingAcct_.get(guard).Withdraw(amount); // COMPILE ERROR
savingsAcct_.get(guard).Deposit(amount); // COMPILE ERROR
do_something_else();
}
We need a way to transfer the ownership from the `unique_lock` to a `strict_lock` during the time we are working with `savingsAcct_` and then restore the ownership on `unique_lock`.
void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
unique_lock<AccountManager> guard1(*this, defer_lock);
if (some_condition()) {
guard1.lock();
}
{
strict_lock<AccountManager> guard(guard1);
checkingAcct_.get(guard).Withdraw(amount);
savingsAcct_.get(guard).Deposit(amount);
}
guard1.unlock();
}
In order to make this code compilable we need to store either a Lockable or a `unique_lock<Lockable>` reference depending on the constructor. We also need to store which kind of reference we have stored, and in the destructor call either to the Lockable `unlock` or restore the ownership.
This seems too complicated to me. Another possibility is to define a nested strict lock class. The drawback is that instead of having only one strict lock we have two and we need either to duplicate every function taking a `strict_lock` or make these function templates. The problem with template functions is that we don't profit anymore of the C++ type system. We must add some static metafunction that checks that the Locker parameter is a strict lock. The problem is that we can not really check this or can we?. The `is_strict_lock` metafunction must be specialized by the strict lock developer. We need to believe it "sur parole". The advantage is that now we can manage with more than two strict locks without changing our code. This is really nice.
Now we need to state that both classes are `strict_lock`s.
template <typename Locker>
struct is_strict_lock : mpl::false_ {};
template <typename Lockable>
struct is_strict_lock<strict_lock<Lockable> > : mpl::true_ {}
template <typename Locker>
struct is_strict_lock<nested_strict_lock<Locker> > : mpl::true_ {}
Well let me show what this `nested_strict_lock` class looks like and the impacts on the `externally_locked` class and the `AccountManager::AMoreComplicatedFunction` function.
First `nested_strict_lock` class will store on a temporary lock the `Locker`, and transfer the lock ownership on the constructor. On destruction it will restore the ownership. Note the use of `lock_traits` and that the `Locker` needs to have a reference to the mutex otherwise an exception is thrown.
template <typename Locker >
class nested_strict_lock
{
BOOST_CONCEPT_ASSERT((MovableLockerConcept<Locker>));
public:
typedef typename lockable_type<Locker>::type lockable_type;
typedef typename syntactic_lock_traits<lockable_type>::lock_error lock_error;
nested_strict_lock(Locker& lock)
: lock_(lock) // Store reference to locker
, tmp_lock_(lock.move()) // Move ownership to temporary locker
{
#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
if (tmp_lock_.mutex()==0) {
lock_=tmp_lock_.move(); // Rollback for coherency purposes
throw lock_error();
}
#endif
if (!tmp_lock_) tmp_lock_.lock(); // ensures it is locked
}
~nested_strict_lock() {
lock_=tmp_lock_.move(); // Move ownership to nesting locker
}
bool owns_lock() const { return true; }
lockable_type* mutex() const { return tmp_lock_.mutex(); }
bool owns_lock(lockable_type* l) const { return l==mutex(); }
private:
Locker& lock_;
Locker tmp_lock_;
};
[/
typedef bool (nested_strict_lock::*bool_type)() const;
operator bool_type() const { return &nested_strict_lock::owns_lock; }
bool operator!() const { return false; }
BOOST_ADRESS_OF_DELETE(nested_strict_lock)
BOOST_HEAP_ALLOCATEION_DELETE(nested_strict_lock)
BOOST_DEFAULT_CONSTRUCTOR_DELETE(nested_strict_lock)
BOOST_COPY_CONSTRUCTOR_DELETE(nested_strict_lock)
BOOST_COPY_ASSIGNEMENT_DELETE(nested_strict_lock)
]
The `externally_locked` get function is now a template function taking a Locker as parameters instead of a `strict_lock`.
We can add test in debug mode that ensure that the Lockable object is locked.
template <typename T, typename Lockable>
class externally_locked {
public:
// ...
template <class Locker>
T& get(Locker& lock) {
BOOST_CONCEPT_ASSERT((StrictLockerConcept<Locker>));
BOOST_STATIC_ASSERT((is_strict_lock<Locker>::value)); // locker is a strict locker "sur parole"
BOOST_STATIC_ASSERT((is_same<Lockable,
typename lockable_type<Locker>::type>::value)); // that locks the same type
#ifndef BOOST_THREAD_EXTERNALLY_LOCKED_DONT_CHECK_OWNERSHIP // define BOOST_THREAD_EXTERNALLY_LOCKED_NO_CHECK_OWNERSHIP if you don't want to check locker ownership
if (! lock ) throw lock_error(); // run time check throw if no locked
#endif
#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
if (!lock.owns_lock(&lockable_)) throw lock_error();
#endif
return obj_;
}
};
The `AccountManager::AMoreComplicatedFunction` function needs only to replace the `strict_lock` by a `nested_strict_lock`.
void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
unique_lock<AccountManager> guard1(*this);
if (some_condition()) {
guard1.lock();
}
{
nested_strict_lock<unique_lock<AccountManager> > guard(guard1);
checkingAcct_.get(guard).Withdraw(amount);
savingsAcct_.get(guard).Deposit(amount);
}
guard1.unlock();
}
[endsect]
[endsect]

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
[/
(C) Copyright 2008-9 Anthony Williams.
(C) Copyright 2008-11 Anthony Williams.
(C) Copyright 2012-2015 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).
@@ -23,25 +24,26 @@
[template unique_future_link[link_text] [link thread.synchronization.futures.reference.unique_future [link_text]]]
[def __unique_future__ [unique_future_link `boost::unique_future`]]
[def __unique_future__ [unique_future_link `future`]]
[def __unique_future `future`]
[template unique_future_get_link[link_text] [link thread.synchronization.futures.reference.unique_future.get [link_text]]]
[def __unique_future_get__ [unique_future_get_link `boost::unique_future<R>::get()`]]
[def __unique_future_get__ [unique_future_get_link `boost::future<R>::get()`]]
[template unique_future_wait_link[link_text] [link thread.synchronization.futures.reference.unique_future.wait [link_text]]]
[def __unique_future_wait__ [unique_future_wait_link `boost::unique_future<R>::wait()`]]
[def __unique_future_wait__ [unique_future_wait_link `boost::future<R>::wait()`]]
[template unique_future_is_ready_link[link_text] [link thread.synchronization.futures.reference.unique_future.is_ready [link_text]]]
[def __unique_future_is_ready__ [unique_future_is_ready_link `boost::unique_future<R>::is_ready()`]]
[def __unique_future_is_ready__ [unique_future_is_ready_link `boost::future<R>::is_ready()`]]
[template unique_future_has_value_link[link_text] [link thread.synchronization.futures.reference.unique_future.has_value [link_text]]]
[def __unique_future_has_value__ [unique_future_has_value_link `boost::unique_future<R>::has_value()`]]
[def __unique_future_has_value__ [unique_future_has_value_link `boost::future<R>::has_value()`]]
[template unique_future_has_exception_link[link_text] [link thread.synchronization.futures.reference.unique_future.has_exception [link_text]]]
[def __unique_future_has_exception__ [unique_future_has_exception_link `boost::unique_future<R>::has_exception()`]]
[def __unique_future_has_exception__ [unique_future_has_exception_link `boost::future<R>::has_exception()`]]
[template unique_future_get_state_link[link_text] [link thread.synchronization.futures.reference.unique_future.get_state [link_text]]]
[def __unique_future_get_state__ [unique_future_get_state_link `boost::unique_future<R>::get_state()`]]
[def __unique_future_get_state__ [unique_future_get_state_link `boost::future<R>::get_state()`]]
[template shared_future_link[link_text] [link thread.synchronization.futures.reference.shared_future [link_text]]]
[def __shared_future__ [shared_future_link `boost::shared_future`]]
@@ -69,6 +71,7 @@
[template packaged_task_link[link_text] [link thread.synchronization.futures.reference.packaged_task [link_text]]]
[def __packaged_task__ [packaged_task_link `boost::packaged_task`]]
[def __packaged_task [packaged_task_link `boost::packaged_task`]]
[template wait_for_any_link[link_text] [link thread.synchronization.futures.reference.wait_for_any [link_text]]]
[def __wait_for_any__ [wait_for_any_link `boost::wait_for_any()`]]
@@ -95,6 +98,9 @@ and __shared_future_get__ returns a `const` reference so that multiple calls to
instance of __unique_future__ into an instance of __shared_future__, thus transferring ownership of the associated asynchronous
result, but not vice-versa.
`boost::async` is a simple way of running asynchronous tasks. A call to `boost::async` returns a __unique_future__ that will contain the result of the task.
You can wait for futures either individually or with one of the __wait_for_any__ and __wait_for_all__ functions.
[endsect]
@@ -114,7 +120,7 @@ place of the return value.
}
boost::packaged_task<int> pt(calculate_the_answer_to_life_the_universe_and_everything);
boost::unique_future<int> fi=pt.get_future();
boost::__unique_future__<int> fi=pt.get_future();
boost::thread task(boost::move(pt)); // launch task on a thread
@@ -132,7 +138,7 @@ future. A promise can therefore be used where the value may come from more than
produce multiple values.
boost::promise<int> pi;
boost::unique_future<int> fi;
boost::__unique_future__<int> fi;
fi=pi.get_future();
pi.set_value(42);
@@ -174,7 +180,7 @@ call to `f.get()` invokes the callback `invoke_lazy_task`, which runs the task t
{
boost::packaged_task<int> task(calculate_the_answer_to_life_the_universe_and_everything);
task.set_wait_callback(invoke_lazy_task);
boost::unique_future<int> f(task.get_future());
boost::__unique_future__<int> f(task.get_future());
assert(f.get()==42);
}
@@ -182,6 +188,277 @@ call to `f.get()` invokes the callback `invoke_lazy_task`, which runs the task t
[endsect]
[section:at_thread_exit Handling Detached Threads and Thread Specific Variables]
Detached threads pose a problem for objects with thread storage duration.
If we use a mechanism other than `thread::__join` to wait for a __thread to complete its work - such as waiting for a future to be ready -
then the destructors of thread specific variables will still be running after the waiting thread has resumed.
This section explain how the standard mechanism can be used to make such synchronization safe by ensuring that the
objects with thread storage duration are destroyed prior to the future being made ready. e.g.
int find_the_answer(); // uses thread specific objects
void thread_func(boost::promise<int>&& p)
{
p.set_value_at_thread_exit(find_the_answer());
}
int main()
{
boost::promise<int> p;
boost::thread t(thread_func,boost::move(p));
t.detach(); // we're going to wait on the future
std::cout<<p.get_future().get()<<std::endl;
}
When the call to `get()` returns, we know that not only is the future value ready, but the thread specific variables
on the other thread have also been destroyed.
Such mechanisms are provided for `boost::condition_variable`, `boost::promise` and `boost::packaged_task`. e.g.
void task_executor(boost::packaged_task<void(int)> task,int param)
{
task.make_ready_at_thread_exit(param); // execute stored task
} // destroy thread specific and wake threads waiting on futures from task
Other threads can wait on a future obtained from the task without having to worry about races due to the execution of
destructors of the thread specific objects from the task's thread.
boost::condition_variable cv;
boost::mutex m;
complex_type the_data;
bool data_ready;
void thread_func()
{
boost::unique_lock<std::mutex> lk(m);
the_data=find_the_answer();
data_ready=true;
boost::notify_all_at_thread_exit(cv,boost::move(lk));
} // destroy thread specific objects, notify cv, unlock mutex
void waiting_thread()
{
boost::unique_lock<std::mutex> lk(m);
while(!data_ready)
{
cv.wait(lk);
}
process(the_data);
}
The waiting thread is guaranteed that the thread specific objects used by `thread_func()` have been destroyed by the time
`process(the_data)` is called. If the lock on `m` is released and re-acquired after setting `data_ready` and before calling
`boost::notify_all_at_thread_exit()` then this does NOT hold, since the thread may return from the wait due to a
spurious wake-up.
[endsect]
[section:async Executing asynchronously]
`boost::async` is a simple way of running asynchronous tasks to make use of the available hardware concurrency.
A call to `boost::async` returns a `boost::future` that will contain the result of the task. Depending on
the launch policy, the task is either run asynchronously on its own thread or synchronously on whichever thread
calls the `wait()` or `get()` member functions on that `future`.
A launch policy of either boost::launch::async, which asks the runtime to create an asynchronous thread,
or boost::launch::deferred, which indicates you simply want to defer the function call until a later time (lazy evaluation).
This argument is optional - if you omit it your function will use the default policy.
For example, consider computing the sum of a very large array. The first task is to not compute asynchronously when
the overhead would be significant. The second task is to split the work into two pieces, one executed by the host
thread and one executed asynchronously.
int parallel_sum(int* data, int size)
{
int sum = 0;
if ( size < 1000 )
for ( int i = 0; i < size; ++i )
sum += data[i];
else {
auto handle = boost::async(parallel_sum, data+size/2, size-size/2);
sum += parallel_sum(data, size/2);
sum += handle.get();
}
return sum;
}
[endsect]
[section:shared Shared Futures]
`shared_future` is designed to be shared between threads,
that is to allow multiple concurrent get operations.
[heading Multiple get]
The second `get()` call in the following example is undefined.
void bad_second_use( type arg ) {
auto ftr = async( [=]{ return work( arg ); } );
if ( cond1 )
{
use1( ftr.get() );
} else
{
use2( ftr.get() );
}
use3( ftr.get() ); // second use is undefined
}
Using a `shared_future` solves the issue
void good_second_use( type arg ) {
shared_future<type> ftr = async( [=]{ return work( arg ); } );
if ( cond1 )
{
use1( ftr.get() );
} else
{
use2( ftr.get() );
}
use3( ftr.get() ); // second use is defined
}
[heading share()]
Naming the return type when declaring the `shared_future` is needed; auto is not available within template argument lists.
Here `share()` could be used to simplify the code
void better_second_use( type arg ) {
auto ftr = async( [=]{ return work( arg ); } ).share();
if ( cond1 )
{
use1( ftr.get() );
} else
{
use2( ftr.get() );
}
use3( ftr.get() ); // second use is defined
}
[heading Writing on get()]
The user can either read or write the future variable.
void write_to_get( type arg ) {
auto ftr = async( [=]{ return work( arg ); } ).share();
if ( cond1 )
{
use1( ftr.get() );
} else
{
if ( cond2 )
use2( ftr.get() );
else
ftr.get() = something(); // assign to non-const reference.
}
use3( ftr.get() ); // second use is defined
}
This works because the `shared_future<>::get()` function returns a non-const reference to the appropriate storage.
Of course the access to this storage must be ensured by the user. The library doesn't ensure the access to the internal storage is thread safe.
There has been some work by the C++ standard committee on an `atomic_future` that behaves as an `atomic` variable, that is thread_safe,
and a `shared_future` that can be shared between several threads, but there were not enough consensus and time to get it ready for C++11.
[endsect]
[section:make_ready_future Making immediate futures easier]
Some functions may know the value at the point of construction. In these cases the value is immediately available,
but needs to be returned as a future or shared_future. By using make_ready_future a future
can be created which holds a pre-computed result in its shared state.
Without these features it is non-trivial to create a future directly from a value.
First a promise must be created, then the promise is set, and lastly the future is retrieved from the promise.
This can now be done with one operation.
[heading make_ready_future]
This function creates a future for a given value. If no value is given then a future<void> is returned.
This function is primarily useful in cases where sometimes, the return value is immediately available, but sometimes
it is not. The example below illustrates, that in an error path the value is known immediately, however in other paths
the function must return an eventual value represented as a future.
boost::future<int> compute(int x)
{
if (x == 0) return boost::make_ready_future(0);
if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error"));
boost::future<int> f1 = boost::async([]() { return x+1; });
return f1;
}
There are two variations of this function. The first takes a value of any type, and returns a future of that type.
The input value is passed to the shared state of the returned future. The second version takes no input and returns a future<void>.
[endsect]
[section:then Associating future continuations]
In asynchronous programming, it is very common for one asynchronous operation, on completion, to invoke a second
operation and pass data to it. The current C++ standard does not allow one to register a continuation to a future.
With `.then`, instead of waiting for the result, a continuation is "attached" to the asynchronous operation, which is
invoked when the result is ready. Continuations registered using the `.then` function will help to avoid blocking waits
or wasting threads on polling, greatly improving the responsiveness and scalability of an application.
`future.then()` provides the ability to sequentially compose two futures by declaring one to be the continuation of another.
With `.then()` the antecedent future is ready (has a value or exception stored in the shared state) before the continuation
starts as instructed by the lambda function.
In the example below the `future<string>` `f2` is registered to be a continuation of `future<int>` `f1` using the `.then()` member
function. This operation takes a lambda function which describes how `f2` should proceed after `f1` is ready.
#include <boost/thread/future.hpp>
using namespace boost;
int main()
{
future<int> f1 = async([]() { return 123; });
future<string> f2 = f1.then([](future<int> f) { return f.get().to_string(); // here .get() won't block });
}
One key feature of this function is the ability to chain multiple asynchronous operations. In asynchronous programming,
it's common to define a sequence of operations, in which each continuation executes only when the previous one completes.
In some cases, the antecedent future produces a value that the continuation accepts as input. By using `future.then()`,
creating a chain of continuations becomes straightforward and intuitive:
myFuture.then(...).then(...).then(...).
Some points to note are:
* Each continuation will not begin until the preceding has completed.
* If an exception is thrown, the following continuation can handle it in a try-catch block
Input Parameters:
* Lambda function: One option which can be considered is to take two functions, one for
success and one for error handling. However this option has not been retained for the moment.
The lambda function takes a future as its input which carries the exception
through. This makes propagating exceptions straightforward. This approach also simplifies the chaining of continuations.
* Executor: Providing an overload to `.then`, to take an executor reference places great flexibility over the execution
of the future in the programmer's hand. As described above, often taking a launch policy is not sufficient for powerful
asynchronous operations. The lifetime of the executor must outlive the continuation.
* Launch policy: if the additional flexibility that the executor provides is not required.
Return values: The decision to return a future was based primarily on the ability to chain multiple continuations using
`.then()`. This benefit of composability gives the programmer incredible control and flexibility over their code. Returning
a `future` object rather than a `shared_future` is also a much cheaper operation thereby improving performance. A
`shared_future` object is not necessary to take advantage of the chaining feature. It is also easy to go from a `future`
to a `shared_future` when needed using future::share().
[endsect]
[include future_ref.qbk]
[endsect]

469
doc/internal_locking.qbk Normal file
View File

@@ -0,0 +1,469 @@
[/
/ Copyright (c) 2008,2014 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)
/]
[section Internal Locking]
[note This tutorial is an adaptation of chapter Concurrency of the Object-Oriented Programming in the BETA Programming Language and of the paper of Andrei Alexandrescu "Multithreading and the C++ Type System" to the Boost library.]
[section Concurrent threads of execution]
Consider, for example, modeling a bank account class that supports simultaneous deposits and withdrawals from multiple locations (arguably the "Hello, World" of multithreaded programming).
From here a component is a model of the `Callable` concept.
I C++11 (Boost) concurrent execution of a component is obtained by means of the `std::thread`(`boost::thread`):
boost::thread thread1(S);
where `S` is a model of `Callable`. The meaning of this expression is that execution of `S()` will take place concurrently with the current thread of execution executing the expression.
The following example includes a bank account of a person (Joe) and two components, one corresponding to a bank agent depositing money in Joe's account, and one representing Joe. Joe will only be withdrawing money from the account:
class BankAccount;
BankAccount JoesAccount;
void bankAgent()
{
for (int i =10; i>0; --i) {
//...
JoesAccount.Deposit(500);
//...
}
}
void Joe() {
for (int i =10; i>0; --i) {
//...
int myPocket = JoesAccount.Withdraw(100);
std::cout << myPocket << std::endl;
//...
}
}
int main() {
//...
boost::thread thread1(bankAgent); // start concurrent execution of bankAgent
boost::thread thread2(Joe); // start concurrent execution of Joe
thread1.join();
thread2.join();
return 0;
}
From time to time, the `bankAgent` will deposit $500 in `JoesAccount`. `Joe` will similarly withdraw $100 from his account. These sentences describe that the `bankAgent` and `Joe` are executed concurrently.
[endsect]
[section Internal locking]
The above example works well as long as the components `bankAgent` and `Joe` doesn't access `JoesAccount` at the same time. There is, however, no guarantee that this will not happen. We may use a mutex to guarantee exclusive access to each bank.
class BankAccount {
boost::mutex mtx_;
int balance_;
public:
void Deposit(int amount) {
mtx_.lock();
balance_ += amount;
mtx_.unlock();
}
void Withdraw(int amount) {
mtx_.lock();
balance_ -= amount;
mtx_.unlock();
}
int GetBalance() {
mtx_.lock();
int b = balance_;
mtx_.unlock();
return b;
}
};
Execution of the `Deposit` and `Withdraw` operations will no longer be able to make simultaneous access to balance.
A mutex is a simple and basic mechanism for obtaining synchronization. In the above example it is relatively easy to be convinced that the synchronization works correctly (in the absence of exception). In a system with several concurrent objects and several shared objects, it may be difficult to describe synchronization by means of mutexes. Programs that make heavy use of mutexes may be difficult to read and write. Instead, we shall introduce a number of generic classes for handling more complicated forms of synchronization and communication.
With the RAII idiom we can simplify a lot this using the scoped locks. In the code below, guard's constructor locks the passed-in object `mtx_`, and guard's destructor unlocks `mtx_`.
class BankAccount {
boost::mutex mtx_; // explicit mutex declaration
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ -= amount;
}
int GetBalance() {
boost::lock_guard<boost::mutex> guard(mtx_);
return balance_;
}
};
The object-level locking idiom doesn't cover the entire richness of a threading model. For example, the model above is quite deadlock-prone when you try to coordinate multi-object transactions. Nonetheless, object-level locking is useful in many cases, and in combination with other mechanisms can provide a satisfactory solution to many threaded access problems in object-oriented programs.
[endsect]
[section Internal and external locking]
The BankAccount class above uses internal locking. Basically, a class that uses internal locking guarantees that any concurrent calls to its public member functions don't corrupt an instance of that class. This is typically ensured by having each public member function acquire a lock on the object upon entry. This way, for any given object of that class, there can be only one member function call active at any moment, so the operations are nicely serialized.
This approach is reasonably easy to implement and has an attractive simplicity. Unfortunately, "simple" might sometimes morph into "simplistic."
Internal locking is insufficient for many real-world synchronization tasks. Imagine that you want to implement an ATM withdrawal transaction with the BankAccount class. The requirements are simple. The ATM transaction consists of two withdrawals-one for the actual money and one for the $2 commission. The two withdrawals must appear in strict sequence; that is, no other transaction can exist between them.
The obvious implementation is erratic:
void ATMWithdrawal(BankAccount& acct, int sum) {
acct.Withdraw(sum);
// preemption possible
acct.Withdraw(2);
}
The problem is that between the two calls above, another thread can perform another operation on the account, thus breaking the second design requirement.
In an attempt to solve this problem, let's lock the account from the outside during the two operations:
void ATMWithdrawal(BankAccount& acct, int sum) {
boost::lock_guard<boost::mutex> guard(acct.mtx_); 1
acct.Withdraw(sum);
acct.Withdraw(2);
}
Notice that the code above doesn't compile, the `mtx_` field is private.
We have two possibilities:
* make `mtx_` public which seems odd
* make the `BankAccount` lockable by adding the lock/unlock functions
We can add these functions explicitly
class BankAccount {
boost::mutex mtx_;
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<boost::mutex> guard(mtx_);
balance_ -= amount;
}
void lock() {
mtx_.lock();
}
void unlock() {
mtx_.unlock();
}
};
or inheriting from a class which add these lockable functions.
The `basic_lockable_adapter` class helps to define the `BankAccount` class as
class BankAccount
: public basic_lockable_adapter<mutex>
{
int balance_;
public:
void Deposit(int amount) {
boost::lock_guard<BankAccount> guard(*this);
balance_ += amount;
}
void Withdraw(int amount) {
boost::lock_guard<BankAccount> guard(*this);
balance_ -= amount;
}
int GetBalance() {
boost::lock_guard<BankAccount> guard(*this);
return balance_;
}
};
and the code that doesn't compiles becomes
void ATMWithdrawal(BankAccount& acct, int sum) {
boost::lock_guard<BankAccount> guard(acct);
acct.Withdraw(sum);
acct.Withdraw(2);
}
Notice that now acct is being locked by Withdraw after it has already been locked by guard. When running such code, one of two things happens.
* Your mutex implementation might support the so-called recursive mutex semantics. This means that the same thread can lock the same mutex several times successfully. In this case, the implementation works but has a performance overhead due to unnecessary locking. (The locking/unlocking sequence in the two Withdraw calls is not needed but performed anyway-and that costs time.)
* Your mutex implementation might not support recursive locking, which means that as soon as you try to acquire it the second time, it blocks-so the ATMWithdrawal function enters the dreaded deadlock.
As `boost::mutex` is not recursive, we need to use its recursive version `boost::recursive_mutex`.
class BankAccount
: public basic_lockable_adapter<recursive_mutex>
{
// ...
};
The caller-ensured locking approach is more flexible and the most efficient, but very dangerous. In an implementation using caller-ensured locking, BankAccount still holds a mutex, but its member functions don't manipulate it at all. Deposit and Withdraw are not thread-safe anymore. Instead, the client code is responsible for locking BankAccount properly.
class BankAccount
: public basic_lockable_adapter<boost:mutex> {
int balance_;
public:
void Deposit(int amount) {
balance_ += amount;
}
void Withdraw(int amount) {
balance_ -= amount;
}
};
Obviously, the caller-ensured locking approach has a safety problem. BankAccount's implementation code is finite, and easy to reach and maintain, but there's an unbounded amount of client code that manipulates BankAccount objects. In designing applications, it's important to differentiate between requirements imposed on bounded code and unbounded code. If your class makes undue requirements on unbounded code, that's usually a sign that encapsulation is out the window.
To conclude, if in designing a multi-threaded class you settle on internal locking, you expose yourself to inefficiency or deadlocks. On the other hand, if you rely on caller-provided locking, you make your class error-prone and difficult to use. Finally, external locking completely avoids the issue by leaving it all to the client code.
[endsect]
[/
[section Monitors]
The use of `mutex` and `lockers`, as in `BankAccount`, is a common way of defining objects shared by two or more concurrent components. The basic_lockable_adapter class was a first step.
We shall therefore introduce an abstraction that makes it easier to define such objects.
The following class describes a so-called monitor pattern.
template <
typename Lockable=mutex
>
class basic_monitor : protected basic_lockable_adapter<Lockable> { // behaves like a BasicLockable for the derived classes
protected:
typedef unspecified synchronizer; // is a strict lock guard
};
[/shared_monitor]
[/monitor]
A basic_monitor object behaves like a `BasicLockable` object but only for the inheriting classes.
Protected inheritance from lockable_adapter provide to all the derived classes all BasicLockable operations. In addition has a protected nested class, synchronizer, used when defining the monitor operations to synchronize the access critical regions. The BankAccount may be described using Monitor in the following way:
class BankAccount : protected basic_monitor<>
{
protected:
int balance_;
public:
BankAccount() : balance_(0) {}
BankAccount(const BankAccount &rhs) {
synchronizer _(*rhs.mutex());
balance_=rhs.balance_;
}
BankAccount& operator=(BankAccount &rhs)
{
if(&rhs == this) return *this;
int balance=0;
{
synchronizer _(*rhs.mutex());
balance=rhs.balance_;
}
synchronizer _(*this->mutex());
balance_=balance;
return *this;
}
void Deposit(int amount) {
synchronizer _(*this->mutex());
balance_ += amount;
}
int Withdraw(int amount) {
synchronizer _(*this->mutex());
balance_ -= amount;
return amount;
}
int GetBalance() {
synchronizer _(*this->mutex());
return balance_;
}
};
In the following, a monitor means some sub-class of monitor. A synchronized operation means an operation using the synchronizer guard defined within some monitor. Monitor is one example of a high-level concurrency abstraction that can be defined by means of mutexes.
[section Monitor Conditions]
It may happen that a component executing an entry operation of a monitor is unable to continue execution due to some condition not being fulfilled. Consider, for instance, a bounded buffer of characters. Such a buffer may be implemented as a monitor with two operations Push and Pull: the Puss operation cannot be executed if the buffer is full, and the Pull operation cannot be executed if the buffer is empty. A sketch of such a buffer monitor may look as
follows:
class sync_buffer {
boost::mutex mtx_; 1
public:
...
bool full() { return in_==out_; }
bool empty() { return in_==(out_%size)+1; }
void push(T& v) {
// wait if buffer is full
data_[in_]=v;
in_ = (in_% size)+1;
}
T pull() {
// wait if buffer is empty
out_ = (out_% size)+1;
return data_[out_];
}
};
The meaning of a wait is that the calling component is delayed until the condition becomes true. We can do that using Boost.Thread condition variables like:
template <typename T, unsigned size>
class sync_buffer
{
typedef boost::mutex mutex_type;
typedef boost::condition_variable condition_type;
typedef boost::unique_lock<mutex_type> unique_lock_type;
mutex_type mtx_;
condition_type not_full_;
condition_type not_empty_;
T data_[size+1];
unsigned in_, out_;
public:
sync_buffer():in_(0), out_(0) {}
bool full() { return out_==(in_+1)%(size+1); }
bool empty() { return out_==in_; }
unsigned get_in() {return in_;}
unsigned get_out() {return out_;}
void push(T v) {
unique_lock_type guard(mtx_); 1
while (full()) { 2
not_full_.wait(guard);
}
data_[in_]=v;
in_ = (in_+1)% (size+1);
not_empty_.notify_one(); 3
}
T pull() {
unique_lock_type guard(mtx_); 4
while (empty()) { 5
not_empty_.wait(guard);
}
unsigned idx = out_;
out_ = (out_+1)% (size+1);
not_full_.notify_one(); 6
return data_[idx];
}
};
The Monitor class replace the nested synchronizer unique_lock with the class `condition_unique_lock` for this purpose:
template <
typename Lockable,
class Condition=condition_safe<typename best_condition<Lockable>::type >
, typename ScopeTag=typename scope_tag<Lockable>::type
>
class condition_unique_lock
: protected unique_lock<Lockable,ScopeTag>
{
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
public:
typedef Lockable lockable_type;
typedef Condition condition;
explicit condition_unique_lock(lockable_type& obj); 1
condition_unique_lock(lockable_type& obj, condition &cond); 2
template <typename Predicate>
condition_unique_lock(lockable_type& obj, condition &cond, Predicate pred); 3
~condition_unique_lock() 4
typedef bool (condition_unique_lock::*bool_type)() const; 5
operator bool_type() const; 6
bool operator!() const { return false; } 7
bool owns_lock() const { return true; } 8
bool is_locking(lockable_type* l) const 9
void relock_on(condition & cond);
template<typename Clock, typename Duration>
void relock_until(condition & cond, chrono::time_point<Clock, Duration> const& abs_time);
template<typename duration_type>
void relock_on_for(condition & cond, duration_type const& rel_time);
template<typename Predicate>
void relock_when(condition &cond, Predicate pred);
template<typename Predicate>
template<typename Clock, typename Duration>
void relock_when_until(condition &cond, Predicate pred,
chrono::time_point<Clock, Duration> const& abs_time);
template<typename Predicate, typename duration_type>
void relock_when_for(condition &cond, Predicate pred,
duration_type const& rel_time);
10
};
We may now give the complete version of the buffer class. The content of the buffer is: `data_[out_+1], data_[out_+2], ... data_R[in_-1]` where all the indexes are modulo size. The buffer is full if `in_=out_` and it is empty if `in_=(out_+1)%size`.
template <typename T, unsigned size>
class sync_buffer : protected basic_monitor<>
{
condition not_full_;
condition not_empty_;
T data_[size+1];
unsigned in_, out_;
struct not_full {
explicit not_full(sync_buffer &b):that_(b){};
bool operator()() const { return !that_.full(); }
sync_buffer &that_;
};
struct not_empty {
explicit not_empty(sync_buffer &b):that_(b){};
bool operator()() const { return !that_.empty(); }
sync_buffer &that_;
};
public:
BOOST_COPY_CONSTRUCTOR_DELETE(sync_buffer) 1
BOOST_COPY_ASSIGNEMENT_DELETE(sync_buffer) 2
sync_buffer():in_(0), out_(0) {}
bool full() { return out_==(in_+1)%(size+1); }
bool empty() { return out_==in_; }
unsigned get_in() {return in_;}
unsigned get_out() {return out_;}
void push(T v) {
synchronizer _(*this->mutex(), not_full_, not_full(*this)); 3
data_[in_]=v;
in_ = (in_+1)% (size+1);
not_empty_.notify_one(); 4
}
T pull() {
synchronizer _(*this->mutex(), not_empty_, not_empty(*this)); 5
unsigned idx = out_;
out_ = (out_+1)% (size+1);
not_full_.notify_one(); 6
return data_[idx];
}
};
Monitors and conditions are useful for describing simple cases of shared objects (by simple we mean a limited use of conditions). If the conditions for delaying a calling component become complicated, the monitor may similarly become difficult to program and read.
[endsect] [/Monitor Conditions]
[endsect] [/Monitors]
]
[endsect] [/Internal Locking]

419
doc/latch.qbk Normal file
View File

@@ -0,0 +1,419 @@
[/
(C) Copyright 2013 Vicente J. Botet Escriba.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:latches Latches -- EXPERIMENTAL]
[////////////////////]
[section Introdcution]
Latches are a thread co-ordination mechanism that allow one or more threads to block until one or more threads have reached a point.
[/
An individual latch is a reusable object; once the operation has been completed, the threads can re-use the same barrier. It is thus useful for managing repeated tasks handled by multiple threads.
A completion latch is like a latch that allows to associate a completion function which will be called once the internal counter reaches the value 0 and all the consumer threads have taken care of the notification.
]
[endsect]
[////////////////]
[section Examples]
Sample use cases for the latch include:
* Setting multiple threads to perform a task, and then waiting until all threads have reached a common point.
* Creating multiple threads, which wait for a signal before advancing beyond a common point.
An example of the first use case would be as follows:
void DoWork(thread_pool* pool) {
latch completion_latch(NTASKS);
for (int i = 0; i < NTASKS; ++i) {
pool->submit([&] {
// perform work
...
completion_latch.count_down();
}));
}
// Block until work is done
completion_latch.wait();
}
An example of the second use case is shown below. We need to load data and then process it using a number of threads. Loading the data is I/O bound, whereas starting threads and creating data structures is CPU bound. By running these in parallel, throughput can be increased.
void DoWork() {
latch start_latch(1);
vector<thread*> workers;
for (int i = 0; i < NTHREADS; ++i) {
workers.push_back(new thread([&] {
// Initialize data structures. This is CPU bound.
...
start_latch.wait();
// perform work
...
}));
}
// Load input data. This is I/O bound.
...
// Threads can now start processing
start_latch.count_down();
}
[/
The completion latches can be used to co-ordinate also a set of threads carrying out a repeated task. The number of threads can be adjusted dynamically to respond to changing requirements.
In the example below, a number of threads are performing a multi-stage task. Some tasks may require fewer steps than others, meaning that some threads may finish before others. We reduce the number of threads waiting on the latch when this happens.
void DoWork() {
Tasks& tasks;
size_t initial_threads;
atomic<size_t> current_threads(initial_threads)
vector<thread*> workers;
// Create a barrier, and set a lambda that will be invoked every time the
// barrier counts down. If one or more active threads have completed,
// reduce the number of threads.
completion_latch task_barrier(n_threads);
task_barrier.then([&] {
task_barrier.reset(current_threads);
});
for (int i = 0; i < n_threads; ++i) {
workers.push_back(new thread([&] {
bool active = true;
while(active) {
Task task = tasks.get();
// perform task
...
if (finished(task)) {
current_threads--;
active = false;
}
task_barrier.count_down_and_wait();
}
});
}
// Read each stage of the task until all stages are complete.
while (!finished()) {
GetNextStage(tasks);
}
}
]
[endsect]
[///////////////////////////]
[section:latch Class `latch`]
#include <boost/thread/latch.hpp>
class latch
{
public:
latch(latch const&) = delete;
latch& operator=(latch const&) = delete;
latch(std::size_t count);
~latch();
void wait();
bool try_wait();
template <class Rep, class Period>
cv_status wait_for(const chrono::duration<Rep, Period>& rel_time);
template <class lock_type, class Clock, class Duration>
cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time);
void count_down();
void count_down_and_wait();
};
[/
void reset(std::size_t count);
]
A latch maintains an internal counter that is initialized when the latch is created. One or more threads may block waiting until the counter is decremented to 0.
Instances of __latch__ are not copyable or movable.
[///////////////////]
[section Constructor `latch(std::size_t)`]
latch(std::size_t count);
[variablelist
[[Effects:] [Construct a latch with is initial value for the internal counter.]]
[[Note:] [The counter could be zero.]]
[[Throws:] [Nothing.]]
]
[endsect]
[//////////////////]
[section Destructor `~latch()`]
~latch();
[variablelist
[[Precondition:] [No threads are waiting or invoking count_down on `*this`.]]
[[Effects:] [Destroys `*this` latch.]]
[[Throws:] [Nothing.]]
]
[endsect]
[/////////////////////////////////////]
[section:wait Member Function `wait()`]
void wait();
[variablelist
[[Effects:] [Block the calling thread until the internal count reaches the value zero. Then all waiting threads
are unblocked. ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to __interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`wait()` is an ['interruption point].]]
]
[endsect]
[/////////////////////////////////////////////]
[section:try_wait Member Function `try_wait()`]
bool try_wait();
[variablelist
[[Returns:] [Returns true if the internal count is 0, and false otherwise. Does not block the calling thread. ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
]]
]
[endsect]
[//////////////////////////////////////////////]
[section:wait_for Member Function `wait_for() `]
template <class Rep, class Period>
cv_status wait_for(const chrono::duration<Rep, Period>& rel_time);
[variablelist
[[Effects:] [Block the calling thread until the internal count reaches the value zero or the duration has been elapsed. If no timeout, all waiting threads are unblocked. ]]
[[Returns:] [cv_status::no_timeout if the internal count is 0, and cv_status::timeout if duration has been elapsed. ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to __interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`wait_for()` is an ['interruption point].]]
]
[endsect]
[/////////////////////////////////////////////////]
[section:wait_until Member Function `wait_until()`]
template <class lock_type, class Clock, class Duration>
cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time);
[variablelist
[[Effects:] [Block the calling thread until the internal count reaches the value zero or the time_point has been reached. If no timeout, all waiting threads are unblocked. ]]
[[Returns:] [cv_status::no_timeout if the internal count is 0, and cv_status::timeout if time_point has been reached.]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to __interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`wait_until()` is an ['interruption point].]]
]
[endsect]
[/////////////////////////////////////////////////]
[section:count_down Member Function `count_down()`]
void count_down();
[variablelist
[[Requires:] [The internal counter is non zero.]]
[[Effects:] [Decrements the internal count by 1, and returns. If the count reaches 0, any threads blocked in wait() will be released. ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to __interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`count_down()` is an ['interruption point].]]
]
[endsect]
[///////////////////////////////////////////////////////////////////]
[section:count_down_and_wait Member Function `count_down_and_wait()`]
void count_down_and_wait();
[variablelist
[[Requires:] [The internal counter is non zero.]]
[[Effects:] [Decrements the internal count by 1. If the resulting count is not 0, blocks the calling thread until the internal count is decremented to 0 by one or more other threads calling count_down() or count_down_and_wait(). ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- __thread_interrupted__ if the wait was interrupted by a call to __interrupt__ on the __thread__ object associated with the current thread of execution.
]]
[[Notes:] [`count_down_and_wait()` is an ['interruption point].]]
]
[endsect]
[///////////////////////////////////////]
[
[section:reset Member Function `reset()`]
reset( size_t );
[variablelist
[[Requires:] [This function may only be invoked when there are no other threads currently inside the waiting functions.]]
[[Returns:] [Resets the latch with a new value for the initial thread count. ]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
]]
]
[endsect]
]
[endsect] [/ latch]
[/
[//////////////////////////////////////////////////]
[section:completion_latch Class `completion_latch `]
#include <boost/thread/completion_latch.hpp>
class completion_latch
{
public:
typedef 'implementation defined' completion_function;
completion_latch(completion_latch const&) = delete;
completion_latch& operator=(completion_latch const&) = delete;
completion_latch(std::size_t count);
template <typename F>
completion_latch(std::size_t count, F&& funct);
~completion_latch();
void wait();
bool try_wait();
template <class Rep, class Period>
cv_status wait_for(const chrono::duration<Rep, Period>& rel_time);
template <class lock_type, class Clock, class Duration>
cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time);
void count_down();
void count_down_and_wait();
void reset(std::size_t count);
template <typename F>
completion_function then(F&& funct);
};
A completion latch is like a latch that allows to associate a completion function which will be called once the internal counter reaches the value 0 and all the consumer threads have taken care of the notification.
Instances of completion_latch are not copyable or movable.
Only the additional functions are documented.
[/////////////////////]
[section:c Constructor]
completion_latch(std::size_t count);
[variablelist
[[Effects:] [Construct a completion_latch with is initial value for the internal counter and a noop completion function.]]
[[Note:] [The counter could be zero and rest later.]]
[[Throws:] [Nothing.]]
]
[endsect]
[///////////////////////////////////////////////]
[section:cf Constructor with completion function]
template <typename F>
completion_latch(std::size_t count, F&& funct);
[variablelist
[[Effects:] [Construct a completion_latch with is initial value for the internal counter and the completion function `funct`.]]
[[Note:] [The counter could be zero and reset later.]]
[[Throws:] [
- Any exception thrown by the copy/move construction of funct.
]]
]
[endsect]
[///////////////////////////////////]
[section:then Member Function `then`]
template <typename F>
completion_function then(F&& funct);
[variablelist
[[Requires:] [This function may only be invoked when there are no other threads currently inside the waiting functions. It may also be invoked from within the registered completion function. ]]
[[Effects:] [Associates the parameter `funct` as completion function of the latch. The next time the internal count reaches 0, this function will be invoked.]]
[[Returns:] [The old completion function.]]
[[Throws:] [
- __thread_resource_error__ if an error occurs.
- Any exception thrown by the copy/move construction of completion functions.
]]
]
[endsect]
[endsect] [/ completion_latch]
]
[endsect] [/ Latches]

117
doc/lockable_adapter.qbk Normal file
View File

@@ -0,0 +1,117 @@
[/
(C) Copyright 2008-2013 Vicente J. Botet Escriba
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[/==========================================================================================]
[section:lockable_adapter_hpp Header `<boost/thread/lockable_adapter.hpp>`]
[/==========================================================================================]
namespace boost {
template <typename Lockable> class basic_lockable_adapter;
template <typename Lockable> class lockable_adapter;
template <typename TimedLock> class timed_lockable_adapter;
template <typename SharableLock> class shared_lockable_adapter;
template <typename UpgradableLock> class upgrade_lockable_adapter;
}
[section Template Class `basic_lockable_adapter<>`]
template <typename Lockable>
class basic_lockable_adapter {
public:
basic_lockable_adapter(basic_lockable_adapter const&) = delete
basic_lockable_adapter& opearator=(basic_lockable_adapter const&) = delete
typedef Lockable mutex_type;
basic_lockable_adapter() {}
void lock();
void unlock();
bool try_lock();
};
[endsect]
[section Template Class `lockable_adapter<>`]
template <typename Lockable>
class lockable_adapter : : public basic_lockable_adapter<Lockable> {
public:
lockable_adapter() {}
bool try_lock();
};
[endsect]
[section Template Class `timed_lockable_adapter<>`]
template <typename TimedLock>
class timed_lockable_adapter : public lockable_adapter<TimedLock> {
public:
timed_lockable_adapter() {}
bool try_lock_until(system_time const & abs_time);
template<typename TimeDuration>
bool try_lock_for(TimeDuration const & relative_time);
void lock_until(system_time const & abs_time);
template<typename TimeDuration>
void lock_for(TimeDuration const & relative_time);
};
[endsect]
[section Template Class `shared_lockable_adapter<>`]
template <typename SharableLock>
class shared_lockable_adapter : public timed_lockable_adapter<SharableLock> {
public:
shared_lockable_adapter() {}
void lock_shared();
bool try_lock_shared();
void unlock_shared();
bool try_lock_shared_until(system_time const& t);
template<typename TimeDuration>
bool try_lock_shared_for(TimeDuration const& t);
template<typename TimeDuration>
void lock_shared_for(TimeDuration const& t);
void lock_shared_until(system_time const& t);
};
[endsect]
[section Template Class `upgrade_lockable_adapter<>`]
template <typename UpgradableLock>
class upgrade_lockable_adapter : public shared_lockable_adapter<UpgradableLock>{
public:
upgrade_lockable_adapter();
void lock_upgrade();
bool try_lock_upgrade();
void unlock_upgrade();
void unlock_upgrade_and_lock();
void unlock_and_lock_upgrade();
void unlock_and_lock_shared();
void unlock_upgrade_and_lock_shared();
bool try_lock_upgrade_until(system_time const&t);
template<typename TimeDuration>
bool try_lock_upgrade_for(TimeDuration const&t);
void lock_upgrade_until(system_time const&t);
template<typename TimeDuration>
void lock_upgrade_for(TimeDuration const&t);
};
[endsect]
[endsect]

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2007-11 Anthony Williams
(C) Copyright 2011-12 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).
@@ -75,10 +76,11 @@ __try_mutex__ is a `typedef` to __mutex__, provided for backwards compatibility
void lock();
void unlock();
bool try_lock();
bool timed_lock(system_time const & abs_time);
template<typename TimeDuration>
bool timed_lock(TimeDuration const & relative_time);
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& t);
typedef platform-specific-type native_handle_type;
native_handle_type native_handle();
@@ -86,6 +88,13 @@ __try_mutex__ is a `typedef` to __mutex__, provided for backwards compatibility
typedef unique_lock<timed_mutex> scoped_timed_lock;
typedef unspecified-type scoped_try_lock;
typedef scoped_timed_lock scoped_lock;
#if defined BOOST_THREAD_PROVIDES_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
bool timed_lock(system_time const & abs_time);
template<typename TimeDuration>
bool timed_lock(TimeDuration const & relative_time);
#endif
};
__timed_mutex__ implements the __timed_lockable_concept__ to provide an exclusive-ownership mutex. At most one thread can own the
@@ -122,7 +131,7 @@ implementation. If no such instance exists, `native_handle()` and `native_handle
~recursive_mutex();
void lock();
bool try_lock();
bool try_lock() noexcept;
void unlock();
typedef platform-specific-type native_handle_type;
@@ -178,13 +187,14 @@ __recursive_try_mutex__ is a `typedef` to __recursive_mutex__, provided for back
~recursive_timed_mutex();
void lock();
bool try_lock();
bool try_lock() noexcept;
void unlock();
bool timed_lock(system_time const & abs_time);
template<typename TimeDuration>
bool timed_lock(TimeDuration const & relative_time);
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& t);
typedef platform-specific-type native_handle_type;
native_handle_type native_handle();
@@ -192,6 +202,13 @@ __recursive_try_mutex__ is a `typedef` to __recursive_mutex__, provided for back
typedef unique_lock<recursive_timed_mutex> scoped_lock;
typedef unspecified-type scoped_try_lock;
typedef scoped_lock scoped_timed_lock;
#if defined BOOST_THREAD_PROVIDES_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
bool timed_lock(system_time const & abs_time);
template<typename TimeDuration>
bool timed_lock(TimeDuration const & relative_time);
#endif
};
__recursive_timed_mutex__ implements the __timed_lockable_concept__ to provide an exclusive-ownership recursive mutex. At most one
@@ -222,3 +239,6 @@ implementation. If no such instance exists, `native_handle()` and `native_handle
[include shared_mutex_ref.qbk]
[endsect]

View File

@@ -7,16 +7,42 @@
[section:once One-time Initialization]
#include <boost/thread/once.hpp>
namespace boost
{
struct once_flag;
template<typename Function, class ...ArgTypes>
inline void call_once(once_flag& flag, Function&& f, ArgTypes&&... args);
#if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0
void call_once(void (*func)(),once_flag& flag);
#endif
}
[warning the variadic prototype is provided only on C++11 compilers supporting variadic templates, otherwise the interface is limited up to 3 parameters.]
[warning the move semantics is ensured only on C++11 compilers supporting SFINAE expression, decltype N3276 and auto. Waiting for a boost::bind that is move aware.]
`boost::call_once` provides a mechanism for ensuring that an initialization routine is run exactly once without data races or deadlocks.
[section:once_flag Typedef `once_flag`]
#include <boost/thread/once.hpp>
#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
struct once_flag
{
constexprr once_flag() noexcept;
once_flag(const once_flag&) = delete;
once_flag& operator=(const once_flag&) = delete;
};
#else
typedef platform-specific-type once_flag;
#define BOOST_ONCE_INIT platform-specific-initializer
#endif
Objects of type `boost::once_flag` shall be initialized with `BOOST_ONCE_INIT`:
Objects of type `boost::once_flag` shall be initialized with `BOOST_ONCE_INIT` if BOOST_THREAD_PROVIDES_ONCE_CXX11 is not defined
boost::once_flag f=BOOST_ONCE_INIT;
@@ -24,26 +50,22 @@ Objects of type `boost::once_flag` shall be initialized with `BOOST_ONCE_INIT`:
[section:call_once Non-member function `call_once`]
#include <boost/thread/once.hpp>
template<typename Callable>
void call_once(once_flag& flag,Callable func);
template<typename Function, class ...ArgTypes>
inline void call_once(once_flag& flag, Function&& f, ArgTypes&&... args);
[variablelist
[[Requires:] [`Callable` is `CopyConstructible`. Copying `func` shall have no side effects, and the effect of calling the copy shall
be equivalent to calling the original. ]]
[[Requires:] [`Function` and each or the `ArgTypes` are `MoveConstructible` and `invoke(decay_copy(boost::forward<Function>(f)), decay_copy(boost::forward<ArgTypes>(args))...)` shall be well formed. ]]
[[Effects:] [Calls to `call_once` on the same `once_flag` object are serialized. If there has been no prior effective `call_once` on
the same `once_flag` object, the argument `func` (or a copy thereof) is called as-if by invoking `func()`, and the invocation of
`call_once` is effective if and only if `func()` returns without exception. If an exception is thrown, the exception is
propagated to the caller. If there has been a prior effective `call_once` on the same `once_flag` object, the `call_once` returns
the same `once_flag` object, the argument `func` is called as-if by invoking `invoke(decay_copy(boost::forward<Function>(f)), decay_copy(boost::forward<ArgTypes>(args))...)`, and the invocation of
`call_once` is effective if and only if `invoke(decay_copy(boost::forward<Function>(f)), decay_copy(boost::forward<ArgTypes>(args))...)` returns without exception. If an exception is thrown, the exception is propagated to the caller. If there has been a prior effective `call_once` on the same `once_flag` object, the `call_once` returns
without invoking `func`. ]]
[[Synchronization:] [The completion of an effective `call_once` invocation on a `once_flag` object, synchronizes with
all subsequent `call_once` invocations on the same `once_flag` object. ]]
[[Throws:] [`thread_resource_error` when the effects cannot be achieved. or any exception propagated from `func`.]]
[[Throws:] [`thread_resource_error` when the effects cannot be achieved or any exception propagated from `func`.]]
[[Note:] [The function passed to `call_once` must not also call
`call_once` passing the same `once_flag` object. This may cause
@@ -54,11 +76,14 @@ proceed even though the call to `call_once` didn't actually call the
function, in which case it could also avoid calling `call_once`
recursively.]]
[[Note:] [On some compilers this function has some restrictions, e.g. if variadic templates are not supported the number of arguments is limited to 3; .]]
]
void call_once(void (*func)(),once_flag& flag);
This second overload is provided for backwards compatibility. The effects of `call_once(func,flag)` shall be the same as those of
This second overload is provided for backwards compatibility and is deprecated. The effects of `call_once(func,flag)` shall be the same as those of
`call_once(flag,func)`.
[endsect]

View File

@@ -1,5 +1,6 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2007-12 Anthony Williams.
(C) Copyright 20012 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).
@@ -11,7 +12,9 @@ __boost_thread__ enables the use of multiple threads of execution with shared da
functions for managing the threads themselves, along with others for synchronizing data between the threads or providing separate
copies of data specific to individual threads.
The __boost_thread__ library was originally written and designed by William E. Kempf. This version is a major rewrite designed to
The __boost_thread__ library was originally written and designed by William E. Kempf (version 1).
Anthony Williams version (version 2) was a major rewrite designed to
closely follow the proposals presented to the C++ Standards Committee, in particular
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html N2497],
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2320.html N2320],
@@ -19,6 +22,9 @@ closely follow the proposals presented to the C++ Standards Committee, in partic
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2139.html N2139], and
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2094.html N2094]
Vicente J. Botet Escriba started (version 3) the adaptation to comply with the accepted Thread C++11 library (Make use of Boost.Chrono and Boost.Move) and the [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking] Howard Hinnant proposal except for the upward conversions.
Some minor non-standard features have been added also as thread attributes, reverse_lock, shared_lock_guard.
In order to use the classes and functions described here, you can
either include the specific headers specified by the descriptions of
each class or function, or include the master thread library header:
@@ -28,3 +34,41 @@ each class or function, or include the master thread library header:
which includes all the other headers in turn.
[endsect]
[section:build Using and building the library]
Boost.Thread is configured following the conventions used to build [@http://www.boost.org/doc/libs/1_48_0/libs/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code libraries with separate source code]. Boost.Thread will import/export the code only if the user has specifically asked for it, by defining either BOOST_ALL_DYN_LINK if they want all boost libraries to be dynamically linked, or BOOST_THREAD_DYN_LINK if they want just this one to be dynamically liked.
The definition of these macros determines whether BOOST_THREAD_USE_DLL is defined. If BOOST_THREAD_USE_DLL is not defined, the library will define BOOST_THREAD_USE_DLL or BOOST_THREAD_USE_LIB depending on whether the platform. On non windows platforms BOOST_THREAD_USE_LIB is defined if is not defined. In windows platforms, BOOST_THREAD_USE_LIB is defined if BOOST_THREAD_USE_DLL and the compiler supports auto-tss cleanup with Boost.Threads (for the time been Msvc and Intel)
The source code compiled when building the library defines a macros BOOST_THREAD_SOURCE that is used to import or export it. The user must not define this macro in any case.
Boost.Thread depends on some non header-only libraries.
* Boost.System: This dependency is mandatory and you will need to link with the library.
* Boost.Chrono: This dependency is optional (see below how to configure) and you will need to link with the library if you use some of the time related interfaces.
* Boost.DateTime: This dependency is mandatory, but even if Boost.DateTime is a non header-only library Boost.Thread uses only parts that are header-only, so in principle you should not need to link with the library.
It seems that there are some IDE (as e.g. Visual Studio) that deduce the libraries that a program needs to link to inspecting the sources. Such IDE could force to link to Boost.DateTime and/or Boost.Chrono.
As the single mandatory dependency is to Boost.System, the following
bjam toolset=msvc-11.0 --build-type=complete --with-thread
will install only boost_thread and boost_system.
Users of such IDE should force the Boost.Chrono and Boost.DateTime build using
bjam toolset=msvc-11.0 --build-type=complete --with-thread --with-chrono --with-date_time
The following section describes all the macros used to configure Boost.Thread.
[include configuration.qbk]
[endsect]

482
doc/parallel.qbk Normal file
View File

@@ -0,0 +1,482 @@
[/
/ Copyright (c) 2014 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)
/]
[//////////////////////////////////////////////////////////]
[section:parallel Parallel - Fork-Join -- EXPERIMENTAL]
[section:fork_join Fork-Join]
[warning These features are experimental and subject to change in future versions. There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
[note These features are based on the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4088.pdf [* n4088 - Task Region R3]] C++1y proposal from P. Halpern, A. Robison, A. Laksberg, H. Sutter, et al. The text that follows has been adapted from this paper to show the differences.]
The major difference respect to the standard proposal is that we are able to use a common executor for several task regions.
[note
Up to now, Boost.Thread doesn't implement the parallel algorithms as defined in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4105.pdf [* n4105 - Information technology Programming languages, their environments and system software interfaces Technical Specification for C++ Extensions for Parallelism]].
]
[////////////////////]
[section Introduction]
This module introduces a C++11/c++14 library function template `task_region` and a library class `task_region_handle`
with member functions `run` and `wait` that together enable developers to write expressive and portable fork-join
parallel code.
The working draft for the Parallelism TS [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4105.pdf [*N4105]] augments the STL algorithms with the inclusion of parallel execution policies. Programmers use these as a basis to write additional high-level algorithms that can be implemented in terms of the provided parallel algorithms. However, the scope of n4105 does not include lower-level mechanisms to express arbitrary fork-join parallelism
The `task_region`, `run` and the `wait` functions provided by this library are based on the `task_group` concept that is a part of the common subset of the PPL and the TBB libraries.
[endsect] [/ Introduction]
[/////////////////////////]
[section:tutorial Tutorial]
Consider an example of a parallel traversal of a tree, where a user-provided function compute is applied to each node of the tree, returning the sum of the results:
template<typename Func>
int traverse(node *n, Func&& compute)
{
int left = 0, right = 0;
task_region([&](task_region_handle& tr) {
if (n->left)
tr.run([&] { left = traverse(n->left, compute); });
if (n->right)
tr.run([&] { right = traverse(n->right, compute); });
});
return compute(n) + left + right;
}
The example above demonstrates the use of two of the functions proposed in this paper, `task_region` and
`task_region_handle::run`.
The `task_region` function delineates a region in a program code potentially containing invocations of tasks
spawned by the `run` member function of the `task_region_handle` class.
The run function spawns a task, a unit of work that is allowed to execute in parallel with respect to the caller.
Any parallel tasks spawned by `run` within the `task_region` are joined back to a single thread of execution at
the end of the `task_region`.
`run` takes a user-provided function object `f` and starts it asynchronously - i.e. it may return before the
execution of `f` completes. The implementation's scheduler may choose to run `f` immediately or delay running
`f` until compute resources become available.
A `task_region_handle` can be constructed only by `task_region` because it has no public constructors.
Thus, `run` can be invoked (directly or indirectly) only from a user-provided function passed to `task_region`:
void g();
void f(task_region_handle& tr)
{
tr.run(g); // OK, invoked from within task_region in h
}
void h()
{
task_region(f);
}
int main()
{
task_region_handle tr; // Error: no public constructor
tr.run(g); // No way to call run outside of a task_region
return 0;
}
[endsect] [/ Tutorial]
[////////////////]
[section:examples Examples]
[section:fib Parallel Fibonacci]
This is surely the worst implementation of the Fibonacci function. Anyway, here it is, as it is simple and shows the fork-join structure clearly. `Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2)`, so the task decomposition is trivial.
int fib_task_region(int n)
{
using boost::experimental::parallel::task_region;
using boost::experimental::parallel::task_region_handle;
if (n == 0) return 0;
if (n == 1) return 1;
int n1;
int n2;
task_region([&](task_region_handle& trh)
{
trh.run([&]
{
n1 = fib_task_region(n - 1);
});
n2 = fib_task_region(n - 2);
});
return n1 + n2;
}
int main()
{
for (int i = 0; i<10; ++i) {
std::cout << fib_task_region(i) << " ";
}
std::cout << std::endl;
}
[endsect] [/ Fib]
[section:fibex Parallel Fibonacci - Specific executor]
The previous example make use of an implementation defined way to spawn the tasks. Often the user wants to master how the task must be spawned. There is an overload of `task_region` that accept an additional `Executor` parameter and a function that takes as parameter a `task_region_handle_gen<Executor>`. `task_region_handle_gen<Executor>` run uses this executor to spawn the tasks.
template <class Ex>
int fib_task_region_gen( Ex& ex, int n)
{
using boost::experimental::parallel::task_region;
using boost::experimental::parallel::task_region_handle_gen;
if (n == 0) return 0;
if (n == 1) return 1;
int n1;
int n2;
task_region(ex, [&](task_region_handle_gen<Ex>& trh) // (2)
{
trh.run([&]
{
n1 = fib_task_region(n - 1);
});
n2 = fib_task_region(n - 2);
});
return n1 + n2;
}
int main()
{
boost::basic_thread_pool tp; // (1)
for (int i = 0; i<10; ++i) {
std::cout << fib_task_region_gen(tp,i) << " ";
}
std::cout << std::endl;
return 0;
}
The specific executor is declared in line (1) and it is used in line (2).
[endsect] [/ Fib ex]
[section:quick_sort Parallel Accumulate]
[endsect] [/ Accumulate]
[section:quick_sort Parallel Quick Sort]
[endsect] [/ QuickSort]
[endsect] [/ Examples]
[////////////////////////]
[section:rationale Design Rationale]
[endsect] [/ Design Rationale]
[endsect] [/ Fork-Join]
[/////////////////////]
[section:ref Reference -- EXPERIMENTAL]
[/////////////////////////]
[section:v1 Parallel V1]
[section:exception_list Header `<experimental/exception_list.hpp>`]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v1
{
class exception_list;
} // v1
} // parallel
} // experimental
} // boost
[/////////////////////////]
[section:exception_list Class `exception_list`]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v1
{
class exception_list: public std::exception
{
public:
typedef 'implementation defined' const_iterator;
~exception_list() noexcept {}
void add(exception_ptr const& e);
size_t size() const noexcept;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const char* what() const noexcept;
};
} // v1
} // parallel
} // experimental
} // boost
[endsect] [/ exception_list]
[endsect] [/ exception_list.hpp]
[endsect] [/ Parallel V1]
[////////////////////////////////////////////////////////////////////]
[section:v2 Parallel V2]
[////////////////////////////////////////////////////////////////////]
[section:concepts Concepts]
[////////////////////////////////////////////////////////////////////]
[section:regionCallable Concept `Region_Callable`]
[endsect] [/ Region_Callable]
[////////////////////////////////////////////////////////////////////]
[section:taskCallable Concept `Task_Callable`]
[endsect] [/ Task_Callable]
[////////////////////////////////////////////////////////////////////]
[endsect] [/ Concepts]
[////////////////////////////////////////////////////////////////////]
[section:task_region Header `<experimental/task_region.hpp>`]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
class task_canceled_exception;
template <class Executor>
class task_region_handle_gen;
using default_executor = 'implementation defined';
class task_region_handle;
template <typename Executor, typename F>
void task_region_final(Executor& ex, F&& f);
template <typename F>
void task_region_final(F&& f);
template <typename Executor, typename F>
void task_region(Executor& ex, F&& f);
template <typename F>
void task_region(F&& f);
} // v2
} // parallel
} // experimental
} // boost
[////////////////////////////////////////////////////////////////////]
[section:task_canceled_exception Class `task_canceled_exception `]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
class task_canceled_exception: public std::exception
{
public:
task_canceled_exception() noexcept;
task_canceled_exception(const task_canceled_exception&) noexcept;
task_canceled_exception& operator=(const task_canceled_exception&) noexcept;
virtual const char* what() const noexcept;
};
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ task_canceled_exception]
[////////////////////////////////////////////////////////////////////]
[section:task_region_handle_gen Template Class `task_region_handle_gen<>`]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
template <class Executor>
class task_region_handle_gen
{
protected:
task_region_handle_gen(Executor& ex);
~task_region_handle_gen();
public:
task_region_handle_gen(const task_region_handle_gen&) = delete;
task_region_handle_gen& operator=(const task_region_handle_gen&) = delete;
task_region_handle_gen* operator&() const = delete;
template<typename F>
void run(F&& f);
void wait();
};
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ task_region_handle_gen]
[////////////////////////////////////////////////////////////////////]
[section:default_executor Class `default_executor `]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
using default_executor = 'implementation defined';
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ default_executor]
[////////////////////////////////////////////////////////////////////]
[section:task_region_handle Class `task_region_handle `]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
class task_region_handle :
public task_region_handle_gen<default_executor>
{
protected:
task_region_handle();
task_region_handle(const task_region_handle&) = delete;
task_region_handle& operator=(const task_region_handle&) = delete;
task_region_handle* operator&() const = delete;
};
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ task_region_handle]
[////////////////////////////////////////////////////////////////////]
[section:task_region_final Template Function `task_region_final `]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
template <typename Executor, typename F>
void task_region_final(Executor& ex, F&& f);
template <typename F>
void task_region_final(F&& f);
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ task_region_final]
[////////////////////////////////////////////////////////////////////]
[section:task_region Template Function `task_region `]
namespace boost
{
namespace experimental
{
namespace parallel
{
inline namespace v2
{
template <typename Executor, typename F>
void task_region(Executor& ex, F&& f);
template <typename F>
void task_region(F&& f);
} // v2
} // parallel
} // experimental
} // boost
[endsect] [/ task_region]
[endsect] [/ task_region.hpp]
[endsect] [/ Parallel V2]
[endsect] [/ Reference]
[endsect] [/ Parallel]

522
doc/scoped_thread.qbk Normal file
View File

@@ -0,0 +1,522 @@
[/
(C) Copyright 2008-9 Anthony Williams.
(C) Copyright 12 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).
]
[section:ScopedThreads Scoped Threads]
[heading Synopsis]
//#include <boost/thread/scoped_thread.hpp>
struct detach;
struct join_if_joinable;
struct interrupt_and_join_if_joinable;
template <class CallableThread = join_if_joinable, class Thread = thread>
class strict_scoped_thread;
template <class CallableThread = join_if_joinable, class Thread = thread>
class scoped_thread;
template <class CallableThread, class Thread = thread>
void swap(scoped_thread<Callable, Thread>& lhs, scoped_threadCallable, Thread>& rhs) noexcept;
[section:motivation Motivation]
Based on the scoped_thread class defined in C++ Concurrency in Action Boost.Thread defines a thread wrapper class that instead of calling terminate if the thread is joinable on destruction, call a specific action given as template parameter.
While the scoped_thread class defined in C++ Concurrency in Action is closer to strict_scoped_thread class that doesn't allows any change in the wrapped thread, Boost.Thread provides a class scoped_thread that provides the same non-deprecated interface as __thread.
[endsect]
[section:tutorial Tutorial]
Scoped Threads are wrappers around a thread that allows the user to state what to do at destruction time. One of the common uses is to join the thread at destruction time so this is the default behavior. This is the single difference respect to a thread. While thread call std::terminate() on the destructor if the thread is joinable, strict_scoped_thread<> or scoped_thread<> join the thread if joinable.
The difference between strict_scoped_thread and scoped_thread is that the strict_scoped_thread hides completely the owned thread and so the user can do nothing with the owned thread other than the specific action given as parameter, while scoped_thread provide the same interface as __thread and forwards all the operations.
boost::strict_scoped_thread<> t1((boost::thread(f)));
//t1.detach(); // compile fails
boost::scoped_thread<> t2((boost::thread(f)));
t2.detach();
[endsect]
[section:thread_functors Free Thread Functors]
//#include <boost/thread/scoped_thread.hpp>
struct detach;
struct join_if_joinable;
struct interrupt_and_join_if_joinable;
[section:detach Functor `detach`]
struct detach
{
template <class Thread>
void operator()(Thread& t)
{
t.detach();
}
};
[endsect]
[section:join_if_joinable Functor `join_if_joinable`]
struct join_if_joinable
{
template <class Thread>
void operator()(Thread& t)
{
if (t.joinable())
{
t.join();
}
}
};
[endsect]
[section:interrupt_and_join_if_joinable Functor `interrupt_and_join_if_joinable`]
struct interrupt_and_join_if_joinable
{
template <class Thread>
void operator()(Thread& t)
{
t.interrupt();
if (t.joinable())
{
t.join();
}
}
};
[endsect]
[endsect]
[section:strict_scoped_thread Class `strict_scoped_thread`]
// #include <boost/thread/scoped_thread.hpp>
template <class CallableThread = join_if_joinable, class Thread = ::boost::thread>
class strict_scoped_thread
{
thread t_; // for exposition purposes only
public:
strict_scoped_thread(strict_scoped_thread const&) = delete;
strict_scoped_thread& operator=(strict_scoped_thread const&) = delete;
explicit strict_scoped_thread(Thread&& t) noexcept;
template <typename F&&, typename ...Args>
explicit strict_scoped_thread(F&&, Args&&...);
~strict_scoped_thread();
};
RAII __thread wrapper adding a specific destroyer allowing to master what can be done at destruction time.
CallableThread: A callable `void(thread&)`.
The default is a `join_if_joinable`.
Thread destructor terminates the program if the __thread is joinable.
This wrapper can be used to join the thread before destroying it.
[heading Example]
boost::strict_scoped_thread<> t((boost::thread(F)));
[section:default_constructor Constructor from a __thread]
explicit strict_scoped_thread(Thread&& t) noexcept;
[variablelist
[[Effects:] [move the thread to own `t_`]]
[[Throws:] [Nothing]]
]
[endsect]
[section:call_constructor Move Constructor from a Callable]
template <typename F&&, typename ...Args>
explicit strict_scoped_thread(F&&, Args&&...);
[variablelist
[[Effects:] [Construct an internal thread in place.]]
[[Postconditions:] [`*this.t_` refers to the newly created thread of execution and `this->get_id()!=thread::id()`.]]
[[Throws:] [Any exception the thread construction can throw.]]
]
[endsect]
[section:destructor Destructor]
~strict_scoped_thread();
[variablelist
[[Effects:] [Equivalent to `CallableThread()(t_)`. ]]
[[Throws:] [Nothing: The `CallableThread()(t_)` should not throw when joining the thread as the scoped variable is on a scope outside the thread function.]]
]
[endsect]
[endsect]
[section:scoped_thread Class `scoped_thread`]
#include <boost/thread/scoped_thread.hpp>
template <class CallableThread, class Thread = thread>
class scoped_thread
{
thread t_; // for exposition purposes only
public:
scoped_thread() noexcept;
scoped_thread(const scoped_thread&) = delete;
scoped_thread& operator=(const scoped_thread&) = delete;
explicit scoped_thread(thread&& th) noexcept;
template <typename F&&, typename ...Args>
explicit scoped_thread(F&&, Args&&...);
~scoped_thread();
// move support
scoped_thread(scoped_thread && x) noexcept;
scoped_thread& operator=(scoped_thread && x) noexcept;
void swap(scoped_thread& x) noexcept;
typedef thread::id id;
id get_id() const noexcept;
bool joinable() const noexcept;
void join();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_join_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_join_until(const chrono::time_point<Clock, Duration>& t);
#endif
void detach();
static unsigned hardware_concurrency() noexcept;
static unsigned physical_concurrency() noexcept;
typedef thread::native_handle_type native_handle_type;
native_handle_type native_handle();
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
void interrupt();
bool interruption_requested() const noexcept;
#endif
};
template <class CallableThread, class Thread = thread>
void swap(scoped_thread<CallableThread,Thread>& lhs,scoped_thread<CallableThread,Thread>& rhs) noexcept;
RAII __thread wrapper adding a specific destroyer allowing to master what can be done at destruction time.
CallableThread: A callable void(thread&).
The default is join_if_joinable.
Thread destructor terminates the program if the thread is joinable.
This wrapper can be used to join the thread before destroying it.
Remark: `scoped_thread` is not a __thread as __thread is not designed to be derived from as a polymorphic type.
Anyway `scoped_thread` can be used in most of the contexts a __thread could be used as it has the
same non-deprecated interface with the exception of the construction.
[heading Example]
boost::scoped_thread<> t((boost::thread(F)));
t.interrupt();
[section:default_constructor Default Constructor]
scoped_thread() noexcept;
[variablelist
[[Effects:] [Constructs a scoped_thread instance that wraps to __not_a_thread__.]]
[[Postconditions:] [`this->get_id()==thread::id()`]]
[[Throws:] [Nothing]]
]
[endsect]
[section:move_constructor Move Constructor]
scoped_thread(scoped_thread&& other) noexcept;
[variablelist
[[Effects:] [Transfers ownership of the scoped_thread managed by `other` (if any) to the newly constructed scoped_thread instance.]]
[[Postconditions:] [`other.get_id()==thread::id()` and `get_id()` returns the value of `other.get_id()` prior to the construction]]
[[Throws:] [Nothing]]
]
[endsect]
[section:move_assignment Move assignment operator]
scoped_thread& operator=(scoped_thread&& other) noexcept;
[variablelist
[[Effects:] [Transfers ownership of the scoped_thread managed by `other` (if
any) to `*this` after having called to `CallableThread()(t_)`.
]]
[[Postconditions:] [`other->get_id()==thread::id()` and `get_id()` returns the value of `other.get_id()` prior to the assignment.]]
[[Throws:] [Nothing: The `CallableThread()(t_)` should not throw when joining the thread as the scoped variable is on a scope outside the thread function.]]
]
[endsect]
[section:thread_constructor Move Constructor from a __thread]
scoped_thread(thread&& t);
[variablelist
[[Effects:] [Transfers ownership of the thread managed by `other` (if any) to the newly constructed scoped_thread instance.]]
[[Postconditions:] [other.get_id()==thread::id() and get_id() returns the value of other.get_id() prior to the construction.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:call_constructor Move Constructor from a Callable]
template <typename F&&, typename ...Args>
explicit scoped_thread(F&&, Args&&...);
[variablelist
[[Effects:] [Construct an internal thread in place.]]
[[Postconditions:] [`*this.t_` refers to the newly created thread of execution and `this->get_id()!=thread::id()`.]]
[[Throws:] [Any exception the thread construction can throw.]]
]
[endsect]
[section:destructor Destructor]
~scoped_thread();
[variablelist
[[Effects:] [Equivalent to `CallableThread()(t_)`. ]]
[[Throws:] [Nothing: The `CallableThread()(t_)` should not throw when joining the thread as the scoped variable is on a scope outside the thread function.]]
]
[endsect]
[section:joinable Member function `joinable()`]
bool joinable() const noexcept;
[variablelist
[[Returns:] [Equivalent to return t_.joinable().]]
[[Throws:] [Nothing]]
]
[endsect]
[section:join Member function `join()`]
void join();
[variablelist
[[Effects:] [Equivalent to t_.join().]]
]
[endsect]
[section:try_join_for Member function `try_join_for()`]
template <class Rep, class Period>
bool try_join_for(const chrono::duration<Rep, Period>& rel_time);
[variablelist
[[Effects:] [Equivalent to return `t_.try_join_for(rel_time)`.]]
]
[endsect]
[section:try_join_until Member function `try_join_until()`]
template <class Clock, class Duration>
bool try_join_until(const chrono::time_point<Clock, Duration>& abs_time);
[variablelist
[[Effects:] [Equivalent to return `t_.try_join_until(abs_time)`.]]
]
[endsect]
[section:detach Member function `detach()`]
void detach();
[variablelist
[[Effects:] [Equivalent to `t_.detach()`.]]
]
[endsect]
[section:get_id Member function `get_id()`]
thread::id get_id() const noexcept;
[variablelist
[[Effects:] [Equivalent to return `t_.get_id()`.]]
]
[endsect]
[section:interrupt Member function `interrupt()`]
void interrupt();
[variablelist
[[Effects:] [Equivalent to `t_.interrupt()`.]]
]
[endsect]
[section:hardware_concurrency Static member function `hardware_concurrency()`]
unsigned hardware_concurrency() noexecpt;
[variablelist
[[Effects:] [Equivalent to return `thread::hardware_concurrency()`.]]
]
[endsect]
[section:physical_concurrency Static member function `physical_concurrency()`]
unsigned physical_concurrency() noexecpt;
[variablelist
[[Effects:] [Equivalent to return `thread::physical_concurrency()`.]]
]
[endsect]
[section:nativehandle Member function `native_handle()`]
typedef thread::native_handle_type native_handle_type;
native_handle_type native_handle();
[variablelist
[[Effects:] [Equivalent to return `t_.native_handle()`.]]
]
[endsect]
[section:swap Member function `swap()`]
void swap(scoped_thread& other) noexcept;
[variablelist
[[Effects:] [Equivalent `t_.swap(other.t_)`.]]
]
[endsect]
[endsect]
[section:non_member_swap Non-member function `swap(scoped_thread&,scoped_thread&)`]
#include <boost/thread/scoped_thread.hpp>
template <class CallableThread, class Thread = thread>
void swap(scoped_thread<Callable, Thread>& lhs, scoped_threadCallable, Thread>& rhs) noexcept;
[variablelist
[[Effects:] [`lhs.swap(rhs)`.]]
]
[endsect]
[endsect]

View File

@@ -5,40 +5,224 @@
http://www.boost.org/LICENSE_1_0.txt).
]
[section:shared_mutex Class `shared_mutex`]
[section:shared_mutex Class `shared_mutex` -- C++14]
#include <boost/thread/shared_mutex.hpp>
class shared_mutex
{
public:
shared_mutex(shared_mutex const&) = delete;
shared_mutex& operator=(shared_mutex const&) = delete;
shared_mutex();
~shared_mutex();
void lock_shared();
bool try_lock_shared();
bool timed_lock_shared(system_time const& timeout);
template <class Rep, class Period>
bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock_shared();
void lock();
bool try_lock();
bool timed_lock(system_time const& timeout);
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
void lock_upgrade();
void unlock_upgrade();
#if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0
// use upgrade_mutex instead.
void lock_upgrade(); // EXTENSION
void unlock_upgrade(); // EXTENSION
void unlock_upgrade_and_lock(); // EXTENSION
void unlock_and_lock_upgrade(); // EXTENSION
void unlock_and_lock_shared(); // EXTENSION
void unlock_upgrade_and_lock_shared(); // EXTENSION
#endif
#if defined BOOST_THREAD_USES_DATETIME
bool timed_lock_shared(system_time const& timeout); // DEPRECATED
bool timed_lock(system_time const& timeout); // DEPRECATED
#endif
void unlock_upgrade_and_lock();
void unlock_and_lock_upgrade();
void unlock_and_lock_shared();
void unlock_upgrade_and_lock_shared();
};
The class `boost::shared_mutex` provides an implementation of a multiple-reader / single-writer mutex. It implements the
__shared_lockable_concept__.
Multiple concurrent calls to __lock_ref__, __try_lock_ref__, `__try_lock_for()`, `__try_lock_until()`, __timed_lock_ref__, __lock_shared_ref__,
`__try_lock_shared_for()`, `__try_lock_shared_until()`, __try_lock_shared_ref__ and __timed_lock_shared_ref__ are permitted.
Note the the lack of reader-writer priority policies in shared_mutex. This is due to an algorithm credited to Alexander Terekhov which lets the OS decide which thread is the next to get the lock without caring whether a unique lock or shared lock is being sought. This results in a complete lack of reader or writer starvation. It is simply fair.
[endsect]
[section:upgrade_mutex Class `upgrade_mutex` -- EXTENSION]
#include <boost/thread/shared_mutex.hpp>
class upgrade_mutex
{
public:
upgrade_mutex(upgrade_mutex const&) = delete;
upgrade_mutex& operator=(upgrade_mutex const&) = delete;
upgrade_mutex();
~upgrade_mutex();
void lock_shared();
bool try_lock_shared();
template <class Rep, class Period>
bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock_shared();
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
void lock_upgrade();
template <class Rep, class Period>
bool try_lock_upgrade_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_upgrade_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock_upgrade();
// Shared <-> Exclusive
#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
bool try_unlock_shared_and_lock();
template <class Rep, class Period>
bool try_unlock_shared_and_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_shared_and_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_and_lock_shared();
// Shared <-> Upgrade
#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
bool try_unlock_shared_and_lock_upgrade();
template <class Rep, class Period>
bool try_unlock_shared_and_lock_upgrade_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_shared_and_lock_upgrade_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_upgrade_and_lock_shared();
// Upgrade <-> Exclusive
void unlock_upgrade_and_lock();
#if defined(BOOST_THREAD_PLATFORM_PTHREAD)
|| defined(BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN)
bool try_unlock_upgrade_and_lock();
template <class Rep, class Period>
bool try_unlock_upgrade_and_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_upgrade_and_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_and_lock_upgrade();
};
The class `boost::upgrade_mutex` provides an implementation of a multiple-reader / single-writer mutex. It implements the
__upgrade_lockable_concept__.
Multiple concurrent calls to __lock_ref__, __try_lock_ref__, __timed_lock_ref__, __lock_shared_ref__, __try_lock_shared_ref__ and
__timed_lock_shared_ref__ shall be permitted.
Multiple concurrent calls to __lock_ref__, __try_lock_ref__, `__try_lock_for()`, `__try_lock_until()`, __timed_lock_ref__, __lock_shared_ref__,
`__try_lock_shared_for()`, `__try_lock_shared_until()`, __try_lock_shared_ref__ and __timed_lock_shared_ref__ are permitted.
[endsect]
[section:null_mutex Class `null_mutex` -- EXTENSION]
#include <boost/thread/null_mutex.hpp>
class null_mutex
{
public:
null_mutex(null_mutex const&) = delete;
null_mutex& operator=(null_mutex const&) = delete;
null_mutex();
~null_mutex();
void lock_shared();
bool try_lock_shared();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_shared();
void lock();
bool try_lock();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock();
void lock_upgrade();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_lock_upgrade_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_upgrade_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_upgrade();
// Shared <-> Exclusive
bool try_unlock_shared_and_lock();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_unlock_shared_and_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_shared_and_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_and_lock_shared();
// Shared <-> Upgrade
bool try_unlock_shared_and_lock_upgrade();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_unlock_shared_and_lock_upgrade_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_shared_and_lock_upgrade_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_upgrade_and_lock_shared();
// Upgrade <-> Exclusive
void unlock_upgrade_and_lock();
bool try_unlock_upgrade_and_lock();
#ifdef BOOST_THREAD_USES_CHRONO
template <class Rep, class Period>
bool try_unlock_upgrade_and_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_unlock_upgrade_and_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
#endif
void unlock_and_lock_upgrade();
};
The class `boost::null_mutex` provides a no-op implementation of a multiple-reader / single-writer mutex. It is a model of the
__UpgradeLockable concept.
[endsect]

1103
doc/sync_queues_ref.qbk Normal file

File diff suppressed because it is too large Load Diff

193
doc/sync_streams.qbk Normal file
View File

@@ -0,0 +1,193 @@
[/
/ Copyright (c) 2013 Vicente J. Botet Escriba
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:ext_locked_streams Externally Locked Streams - EXPERIMENTAL]
[warning These features are experimental and subject to change in future versions. There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
[note These features are based on the [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3535.html [*N3535 - C++ Streams Mutex]] C++1y proposal, even if the library proposes al alternative interface.]
[section:tutorial Tutorial]
[endsect] [/tutorial]
[/////////////////////]
[section:ref Reference]
#include <boost/thread/externally_locked_stream.hpp>
namespace boost
{
template <typename Stream, typename RecursiveMutex=recursive_mutex>
class externally_locked_stream;
template <class Stream, typename RecursiveMutex=recursive_mutex>
class stream_guard;
template <typename Stream, typename RecursiveMutex>
struct is_strict_lock_sur_parole<stream_guard<Stream, RecursiveMutex> > : true_type {};
// Stream-like operators
template <typename Stream, typename RecursiveMutex, typename T>
const stream_guard<Stream, RecursiveMutex>& operator<<(const stream_guard<Stream, RecursiveMutex>& lck, T arg);
template <typename Stream, typename RecursiveMutex>
const stream_guard<Stream, RecursiveMutex>&
operator<<(const stream_guard<Stream, RecursiveMutex>& lck, Stream& (*arg)(Stream&));
template <typename Stream, typename RecursiveMutex, typename T>
const stream_guard<Stream, RecursiveMutex>&
operator>>(const stream_guard<Stream, RecursiveMutex>& lck, T& arg);
template <typename Stream, typename RecursiveMutex, typename T>
stream_guard<Stream, RecursiveMutex>
operator<<(externally_locked_stream<Stream, RecursiveMutex>& mtx, T arg);
template <typename Stream, typename RecursiveMutex>
stream_guard<Stream, RecursiveMutex>
operator<<(externally_locked_stream<Stream, RecursiveMutex>& mtx, Stream& (*arg)(Stream&));
template <typename Stream, typename RecursiveMutex, typename T>
stream_guard<Stream, RecursiveMutex>
operator>>(externally_locked_stream<Stream, RecursiveMutex>& mtx, T& arg);
}
[/////////////////////////////////////////]
[section:stream_guard Class `stream_guard`]
#include <boost/thread/externally_locked_stream.hpp>
namespace boost
{
template <class Stream, typename RecursiveMutex=recursive_mutex>
class stream_guard
{
public:
typedef typename externally_locked_stream<Stream, RecursiveMutex>::mutex_type mutex_type;
// Constructors, Assignment and Destructors
stream_guard(stream_guard const&) = delete;
stream_guard& operator=(stream_guard const&) = delete;
stream_guard(externally_locked_stream<Stream, RecursiveMutex>& mtx);
stream_guard(externally_locked_stream<Stream, RecursiveMutex>& mtx, adopt_lock_t);
stream_guard(stream_guard&& rhs);
~stream_guard();
// Observers
bool owns_lock(mutex_type const* l) const BOOST_NOEXCEPT;
Stream& get() const;
Stream& bypass() const;
};
}
`stream_guard` is a model of __StrictLock.
[//////////////////////////////////////////////////]
[section:constructor `stream_guard(mutex_type & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_ref_link `m.lock()`].]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[////////////////////////////////////////////////////////////////////////////]
[section:constructor_adopt `stream_guard(mutex_type & m,boost::adopt_lock_t)`]
[variablelist
[[Precondition:] [The current thread owns a lock on `m` equivalent to one
obtained by a call to [lock_ref_link `m.lock()`].]]
[[Effects:] [Stores a reference to `m`. Takes ownership of the lock state of
`m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[//////////////////////////////////////////////////////////]
[section:move_constructor `stream_guard(stream_guard && m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_ref_link `m.lock()`].]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[////////////////////////////////////]
[section:destructor `~stream_guard()`]
[variablelist
[[Effects:] [Invokes [unlock_ref_link `m.unlock()`] on the __lockable_concept_type__
object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[//////////////////////////////////////////////////////////////////]
[section:externally_locked_stream Class `externally_locked_stream `]
#include <boost/thread/externally_locked_stream.hpp>
namespace boost
{
template <typename Stream, typename RecursiveMutex>
class externally_locked_stream: public externally_locked<Stream&, RecursiveMutex>
{
public:
// Constructors, Assignment and Destructors
externally_locked_stream(externally_locked_stream const&) = delete;
externally_locked_stream& operator=(externally_locked_stream const&) = delete;
externally_locked_stream(Stream& stream, RecursiveMutex& mtx);
// Modifiers
stream_guard<Stream, RecursiveMutex> hold();
};
}
`externally_locked_stream` cloaks a reference to a stream of type `Stream`, and actually
provides full access to that object through the `get` member functions, provided you
pass a reference to a strict lock object.
[////////////////////////////////////////////////////////////////////////]
[section:constructor `externally_locked_stream(Stream&, RecursiveMutex&)`]
[variablelist
[[Effects:] [Constructs an externally locked object storing the cloaked reference object and its locking mutex.]]
]
[endsect]
[/////////////////////]
[section:hold `hold()`]
[variablelist
[[Returns:] [A stream_guard which will hold the mutex during it lifetime .]]
]
[endsect]
[endsect]
[endsect] [/ref]
[endsect] [/Externally Locked Streams]

66
doc/sync_tutorial.qbk Normal file
View File

@@ -0,0 +1,66 @@
[/
(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).
]
[section:tutorial Tutorial]
[@http://web.archive.org/web/20140531071228/http://home.roadrunner.com/~hinnant/mutexes/locking.html Handling mutexes in C++] is an excellent tutorial. You need just replace std and ting by boost.
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2406.html Mutex, Lock, Condition Variable Rationale] adds rationale for the design decisions made for mutexes, locks and condition variables.
In addition to the C++11 standard locks, Boost.Thread provides other locks and some utilities that help the user to make their code thread-safe.
[include internal_locking.qbk]
[include external_locking.qbk]
[section:with Executing Around a Function]
In particular, the library provides a way to lock around the execution of a function.
template <class Lockable, class Function, class... Args>
auto with_lock_guard(
Lockable& m,
Function&& func,
Args&&... args
) -> decltype(func(boost::forward<Args>(args)...)) {
boost::lock_guard<Lockable> lock(m);
return func(boost::forward<Args>(args)...);
}
that can be used with regular functions:
int func(int, int&);
//...
boost::mutex m;
int a;
int result = boost::with_lock_guard(m, func, 1, boost::ref(a));
with boost::bind:
int result = boost::with_lock_guard(
m, boost::bind(func, 2, boost::ref(a))
);
or with lambda expression:
int a;
int result = boost::with_lock_guard(
m,
[&a](int x) {
// this scope is protected by mutex m
a = 3;
return x + 4;
},
5
);
[endsect] [/ With]
[endsect] [/ Tutorial]

147
doc/synchronized_value.qbk Normal file
View File

@@ -0,0 +1,147 @@
[/
/ Copyright (c) 2013 Vicente J. Botet Escriba
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:synchronized_valuesxxx Synchronized Values - EXPERIMENTAL]
[warning These features are experimental and subject to change in future versions. There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
[section:tutorial Tutorial]
[note This tutorial is an adaptation of the paper of Anthony Williams "Enforcing Correct Mutex Usage with Synchronized Values" to the Boost library.]
[section The Problem with Mutexes]
The key problem with protecting shared data with a mutex is that there is no easy way to associate the mutex with the data. It is thus relatively easy to accidentally write code that fails to lock the right mutex - or even locks the wrong mutex - and the compiler will not help you.
std::mutex m1;
int value1;
std::mutex m2;
int value2;
int readValue1()
{
boost::lock_guard<boost::mutex> lk(m1);
return value1;
}
int readValue2()
{
boost::lock_guard<boost::mutex> lk(m1); // oops: wrong mutex
return value2;
}
Moreover, managing the mutex lock also clutters the source code, making it harder to see what is really going on.
The use of synchronized_value solves both these problems - the mutex is intimately tied to the value, so you cannot access it without a lock, and yet access semantics are still straightforward. For simple accesses, synchronized_value behaves like a pointer-to-T; for example:
boost::synchronized_value<std::string> value3;
std::string readValue3()
{
return *value3;
}
void setValue3(std::string const& newVal)
{
*value3=newVal;
}
void appendToValue3(std::string const& extra)
{
value3->append(extra);
}
Both forms of pointer dereference return a proxy object rather than a real reference, to ensure that the lock on the mutex is held across the assignment or method call, but this is transparent to the user.
[endsect] [/The Problem with Mutexes]
[section Beyond Simple Accesses]
The pointer-like semantics work very well for simple accesses such as assignment and calls to member functions. However, sometimes you need to perform an operation that requires multiple accesses under protection of the same lock, and that's what the synchronize() method provides.
By calling synchronize() you obtain a strict_lock_ptr object that holds a lock on the mutex protecting the data, and which can be used to access the protected data. The lock is held until the strict_lock_ptr object is destroyed, so you can safely perform multi-part operations. The strict_lock_ptr object also acts as a pointer-to-T, just like synchronized_value does, but this time the lock is already held. For example, the following function adds a trailing slash to a path held in a synchronized_value. The use of the strict_lock_ptr object ensures that the string hasn't changed in between the query and the update.
void addTrailingSlashIfMissing(boost::synchronized_value<std::string> & path)
{
boost::strict_lock_ptr<std::string> u=path.synchronize();
if(u->empty() || (*u->rbegin()!='/'))
{
*u+='/';
}
}
[endsect] [/Beyond Simple Accesses]
[section Operations Across Multiple Objects]
Though synchronized_value works very well for protecting a single object of type T, nothing that we've seen so far solves the problem of operations that require atomic access to multiple objects unless those objects can be combined within a single structure protected by a single mutex.
One way to protect access to two synchronized_value objects is to construct a strict_lock_ptr for each object and use those to access the respective protected values; for instance:
synchronized_value<std::queue<MessageType> > q1,q2;
void transferMessage()
{
strict_lock_ptr<std::queue<MessageType> > u1 = q1.synchronize();
strict_lock_ptr<std::queue<MessageType> > u2 = q2.synchronize();
if(!u1->empty())
{
u2->push_back(u1->front());
u1->pop_front();
}
}
This works well in some scenarios, but not all -- if the same two objects are updated together in different sections of code then you need to take care to ensure that the strict_lock_ptr objects are constructed in the same sequence in all cases, otherwise you have the potential for deadlock. This is just the same as when acquiring any two mutexes.
In order to be able to use the dead-lock free lock algorithms we need to use instead unique_lock_ptr, which is Lockable.
synchronized_value<std::queue<MessageType> > q1,q2;
void transferMessage()
{
unique_lock_ptr<std::queue<MessageType> > u1 = q1.unique_synchronize(boost::defer_lock);
unique_lock_ptr<std::queue<MessageType> > u2 = q2.unique_synchronize(boost::defer_lock);
boost::lock(u1,u2); // dead-lock free algorithm
if(!u1->empty())
{
u2->push_back(u1->front());
u1->pop_front();
}
}
While the preceding takes care of dead-lock, the access to the synchronized_value via unique_lock_ptr requires a lock that is not forced by the interface.
An alternative on compilers providing a standard library that supports movable std::tuple is to use the free synchronize function, which will lock all the mutexes associated to the synchronized values and return a tuple os strict_lock_ptr.
synchronized_value<std::queue<MessageType> > q1,q2;
void transferMessage()
{
auto lks = synchronize(u1,u2); // dead-lock free algorithm
if(!std::get<1>(lks)->empty())
{
std::get<2>(lks)->push_back(u1->front());
std::get<1>(lks)->pop_front();
}
}
[endsect] [/Operations Across Multiple Objects]
[section Value semantics]
synchronized_value has value semantics even if the syntax lets is close to a pointer (this is just because we are unable to define smart references).
[endsect] [/Value semantics]
[endsect] [/tutorial]
[include synchronized_value_ref.qbk]
[endsect] [/Synchronized values]

View File

@@ -0,0 +1,415 @@
[/
/ Copyright (c) 2013 Vicente J. Botet Escriba
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:synchronized_value_ref Reference ]
#include <boost/thread/synchronized_value.hpp>
namespace boost
{
template<typename T, typename Lockable = mutex>
class synchronized_value;
// Specialized swap algorithm
template <typename T, typename L>
void swap(synchronized_value<T,L> & lhs, synchronized_value<T,L> & rhs);
template <typename T, typename L>
void swap(synchronized_value<T,L> & lhs, T & rhs);
template <typename T, typename L>
void swap(T & lhs, synchronized_value<T,L> & rhs);
// Hash support
template<typename T, typename L>
struct hash<synchronized_value<T,L> >;
// Comparison
template <typename T, typename L>
bool operator==(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
template <typename T, typename L>
bool operator!=(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
template <typename T, typename L>
bool operator<(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
template <typename T, typename L>
bool operator<=(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
template <typename T, typename L>
bool operator>(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
template <typename T, typename L>
bool operator>=(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
// Comparison with T
template <typename T, typename L>
bool operator==(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator!=(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator<(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator<=(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator>(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator>=(T const& lhs, synchronized_value<T,L> const&rhs);
template <typename T, typename L>
bool operator==(synchronized_value<T,L> const& lhs, T const& rhs);
template <typename T, typename L>
bool operator!=(synchronized_value<T,L> const& lhs, T const& rhs);
template <typename T, typename L>
bool operator<(synchronized_value<T,L> const& lhs, T const& rhs);
template <typename T, typename L>
bool operator<=(synchronized_value<T,L> const& lhs, T const& rhs);
template <typename T, typename L>
bool operator>(synchronized_value<T,L> const& lhs, T const& rhs);
template <typename T, typename L>
bool operator>=(synchronized_value<T,L> const& lhs, T const& rhs);
#if ! defined(BOOST_THREAD_NO_SYNCHRONIZE)
template <typename ...SV>
std::tuple<typename synchronized_value_strict_lock_ptr<SV>::type ...> synchronize(SV& ...sv);
#endif
}
[section:synchronized_value Class `synchronized_value`]
#include <boost/thread/synchronized_value.hpp>
namespace boost
{
template<typename T, typename Lockable = mutex>
class synchronized_value
{
public:
typedef T value_type;
typedef Lockable mutex_type;
synchronized_value() noexcept(is_nothrow_default_constructible<T>::value);
synchronized_value(T const& other) noexcept(is_nothrow_copy_constructible<T>::value);
synchronized_value(T&& other) noexcept(is_nothrow_move_constructible<T>::value);
synchronized_value(synchronized_value const& rhs);
synchronized_value(synchronized_value&& other);
// mutation
synchronized_value& operator=(synchronized_value const& rhs);
synchronized_value& operator=(value_type const& val);
void swap(synchronized_value & rhs);
void swap(value_type & rhs);
//observers
T get() const;
#if ! defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator T() const;
#endif
strict_lock_ptr<T,Lockable> operator->();
const_strict_lock_ptr<T,Lockable> operator->() const;
strict_lock_ptr<T,Lockable> synchronize();
const_strict_lock_ptr<T,Lockable> synchronize() const;
deref_value operator*();;
const_deref_value operator*() const;
private:
T value_; // for exposition only
mutable mutex_type mtx_; // for exposition only
};
}
[variablelist
[[Requires:] [`Lockable` is `Lockable`.]]
]
[section:constructor `synchronized_value()`]
synchronized_value() noexcept(is_nothrow_default_constructible<T>::value);
[variablelist
[[Requires:] [`T` is `DefaultConstructible`.]]
[[Effects:] [Default constructs the cloaked value_type]]
[[Throws:] [Any exception thrown by `value_type()`.]]
]
[endsect]
[section:constructor_vt `synchronized_value(T const&)`]
synchronized_value(T const& other) noexcept(is_nothrow_copy_constructible<T>::value);
[variablelist
[[Requires:] [`T` is `CopyConstructible`.]]
[[Effects:] [Copy constructs the cloaked value_type using the parameter `other`]]
[[Throws:] [Any exception thrown by `value_type(other)`.]]
]
[endsect]
[section:copy_cons `synchronized_value(synchronized_value const&)`]
synchronized_value(synchronized_value const& rhs);
[variablelist
[[Requires:] [`T` is `DefaultConstructible` and `Assignable`.]]
[[Effects:] [Assigns the value on a scope protected by the mutex of the rhs. The mutex is not copied.]]
[[Throws:] [Any exception thrown by `value_type()` or `value_type& operator=(value_type&)` or `mtx_.lock()`.]]
]
[endsect]
[section:move_vt `synchronized_value(T&&)`]
synchronized_value(T&& other) noexcept(is_nothrow_move_constructible<T>::value);
[variablelist
[[Requires:] [`T` is `MoveConstructible `.]]
[[Effects:] [Move constructs the cloaked value_type]]
[[Throws:] [Any exception thrown by `value_type(value_type&&)`.]]
]
[endsect]
[section:move `synchronized_value(synchronized_value&&)`]
synchronized_value(synchronized_value&& other);
[variablelist
[[Requires:] [`T` is `MoveConstructible `.]]
[[Effects:] [Move constructs the cloaked value_type]]
[[Throws:] [Any exception thrown by `value_type(value_type&&)` or `mtx_.lock()`.]]
]
[endsect]
[section:assign `operator=(synchronized_value const&)`]
synchronized_value& operator=(synchronized_value const& rhs);
[variablelist
[[Requires:] [`T` is `Assignable`.]]
[[Effects:] [Copies the underlying value on a scope protected by the two mutexes. The mutex is not copied. The locks are acquired avoiding deadlock. For example, there is no problem if one thread assigns `a = b` and the other assigns `b = a`.]]
[[Return:] [`*this`]]
[[Throws:] [Any exception thrown by `value_type& operator(value_type const&)` or `mtx_.lock()`.]]
]
[endsect]
[section:assign_vt `operator=(T const&)`]
synchronized_value& operator=(value_type const& val);
[variablelist
[[Requires:] [`T` is `Assignable`.]]
[[Effects:] [Copies the value on a scope protected by the mutex.]]
[[Return:] [`*this`]]
[[Throws:] [Any exception thrown by `value_type& operator(value_type const&)` or `mtx_.lock()`.]]
]
[endsect]
[section:get `get() const`]
T get() const;
[variablelist
[[Requires:] [`T` is `CopyConstructible`.]]
[[Return:] [`A copy of the protected value obtained on a scope protected by the mutex.`]]
[[Throws:] [Any exception thrown by `value_type(value_type const&)` or `mtx_.lock()`.]]
]
[endsect]
[section:T `operator T() const`]
#if ! defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator T() const;
#endif
[variablelist
[[Requires:] [`T` is `CopyConstructible`.]]
[[Return:] [`A copy of the protected value obtained on a scope protected by the mutex.`]]
[[Throws:] [Any exception thrown by `value_type(value_type const&)` or `mtx_.lock()`.]]
]
[endsect]
[section:swap `swap(synchronized_value&)`]
void swap(synchronized_value & rhs);
[variablelist
[[Requires:] [`T` is `Assignable`.]]
[[Effects:] [Swaps the data on a scope protected by both mutex. Both mutex are acquired to avoid dead-lock. The mutexes are not swapped.]]
[[Throws:] [Any exception thrown by `swap(value_, rhs.value)` or `mtx_.lock()` or `rhs_.mtx_.lock()`.]]
]
[endsect]
[section:swap_vt `swap(synchronized_value&)`]
void swap(value_type & rhs);
[variablelist
[[Requires:] [`T` is `Swapable`.]]
[[Effects:] [Swaps the data on a scope protected by both mutex. Both mutex are acquired to avoid dead-lock. The mutexes are not swapped.]]
[[Throws:] [Any exception thrown by `swap(value_, rhs)` or `mtx_.lock()`.]]
]
[endsect]
[section:indir `operator->()`]
strict_lock_ptr<T,Lockable> operator->();
Essentially calling a method `obj->foo(x, y, z)` calls the method `foo(x, y, z)` inside a critical section as long-lived as the call itself.
[variablelist
[[Return:] [`A strict_lock_ptr<>.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:indir_const `operator->() const`]
const_strict_lock_ptr<T,Lockable> operator->() const;
If the `synchronized_value` object involved is const-qualified, then you'll only be able to call const methods
through `operator->`. So, for example, `vec->push_back("xyz")` won't work if `vec` were const-qualified.
The locking mechanism capitalizes on the assumption that const methods don't modify their underlying data.
[variablelist
[[Return:] [`A const_strict_lock_ptr <>.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:synchronize `synchronize()`]
strict_lock_ptr<T,Lockable> synchronize();
The synchronize() factory make easier to lock on a scope. As discussed, `operator->` can only lock over the duration of a call, so it is insufficient for complex operations. With `synchronize()` you get to lock the object in a scoped and to directly access the object inside that scope.
[*Example:]
void fun(synchronized_value<vector<int>> & vec) {
auto vec2=vec.synchronize();
vec2.push_back(42);
assert(vec2.back() == 42);
}
[variablelist
[[Return:] [`A strict_lock_ptr <>.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:synchronize_const `synchronize() const`]
const_strict_lock_ptr<T,Lockable> synchronize() const;
[variablelist
[[Return:] [`A const_strict_lock_ptr <>.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:deref `operator*()`]
deref_value operator*();;
[variablelist
[[Return:] [`A an instance of a class that locks the mutex on construction and unlocks it on destruction and provides implicit conversion to a reference to the protected value.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:deref_const `operator*() const`]
const_deref_value operator*() const;
[variablelist
[[Return:] [`A an instance of a class that locks the mutex on construction and unlocks it on destruction and provides implicit conversion to a constant reference to the protected value.`]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[section:synchronize Non-Member Function `synchronize`]
#include <boost/thread/synchronized_value.hpp>
namespace boost
{
#if ! defined(BOOST_THREAD_NO_SYNCHRONIZE)
template <typename ...SV>
std::tuple<typename synchronized_value_strict_lock_ptr<SV>::type ...> synchronize(SV& ...sv);
#endif
}
[endsect]
[endsect]

View File

@@ -1,14 +1,17 @@
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2008-11 Anthony Williams
(C) Copyright 2011-12 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).
]
[article Thread
[quickbook 1.4]
[authors [Williams, Anthony]]
[copyright 2007-8 Anthony Williams]
[library Thread
[quickbook 1.5]
[version 4.7.2]
[authors [Williams, Anthony] [Botet Escriba, Vicente J.]]
[copyright 2007-11 Anthony Williams]
[copyright 2011-16 Vicente J. Botet Escriba]
[purpose C++ Library for launching threads and synchronizing data between them]
[category text]
[license
@@ -21,6 +24,11 @@
[template lockable_concept_link[link_text] [link thread.synchronization.mutex_concepts.lockable [link_text]]]
[def __lockable_concept__ [lockable_concept_link `Lockable` concept]]
[def __lockable_concept_type__ [lockable_concept_link `Lockable`]]
[def __BasicLockable [link thread.synchronization.mutex_concepts.basic_lockable `BasicLockable`]]
[def __Lockable [link thread.synchronization.mutex_concepts.lockable `Lockable`]]
[def __TimedLockable [link thread.synchronization.mutex_concepts.timed_lockable `TimedLockable`]]
[def __SharedLockable [link thread.synchronization.mutex_concepts.shared_lockable `SharedLockable`]]
[def __UpgradeLockable [link thread.synchronization.mutex_concepts.upgrade_lockable `UpgradeLockable`]]
[template timed_lockable_concept_link[link_text] [link thread.synchronization.mutex_concepts.timed_lockable [link_text]]]
[def __timed_lockable_concept__ [timed_lockable_concept_link `TimedLockable` concept]]
@@ -35,8 +43,9 @@
[def __upgrade_lockable_concept_type__ [upgrade_lockable_concept_link `UpgradeLockable`]]
[template lock_ref_link[link_text] [link thread.synchronization.mutex_concepts.lockable.lock [link_text]]]
[template lock_ref_link[link_text] [link thread.synchronization.mutex_concepts.basic_lockable.lock [link_text]]]
[def __lock_ref__ [lock_ref_link `lock()`]]
[def __lock [link thread.synchronization.mutex_concepts.basic_lockable.lock `lock`]]
[template lock_multiple_ref_link[link_text] [link thread.synchronization.lock_functions.lock_multiple [link_text]]]
[def __lock_multiple_ref__ [lock_multiple_ref_link `lock()`]]
@@ -44,50 +53,89 @@
[template try_lock_multiple_ref_link[link_text] [link thread.synchronization.lock_functions.try_lock_multiple [link_text]]]
[def __try_lock_multiple_ref__ [try_lock_multiple_ref_link `try_lock()`]]
[template unlock_ref_link[link_text] [link thread.synchronization.mutex_concepts.lockable.unlock [link_text]]]
[template unlock_ref_link[link_text] [link thread.synchronization.mutex_concepts.basic_lockable.unlock [link_text]]]
[def __unlock_ref__ [unlock_ref_link `unlock()`]]
[def __unlock [link thread.synchronization.mutex_concepts.basic_lockable.unlock `unlock`]]
[template try_lock_ref_link[link_text] [link thread.synchronization.mutex_concepts.lockable.try_lock [link_text]]]
[def __try_lock_ref__ [try_lock_ref_link `try_lock()`]]
[def __try_lock [link thread.synchronization.mutex_concepts.lockable.try_lock `try_lock`]]
[template timed_lock_ref_link[link_text] [link thread.synchronization.mutex_concepts.timed_lockable.timed_lock [link_text]]]
[def __timed_lock_ref__ [timed_lock_ref_link `timed_lock()`]]
[def __timed_lock [link thread.synchronization.mutex_concepts.timed_lockable.timed_lock `timed_lock`]]
[def __try_lock_for [link thread.synchronization.mutex_concepts.timed_lockable.try_lock_for `try_lock_for`]]
[def __try_lock_until [link thread.synchronization.mutex_concepts.timed_lockable.try_lock_until `try_lock_until`]]
[template timed_lock_duration_ref_link[link_text] [link thread.synchronization.mutex_concepts.timed_lockable.timed_lock_duration [link_text]]]
[def __timed_lock_duration_ref__ [timed_lock_duration_ref_link `timed_lock()`]]
[def __timed_lock_duration [link thread.synchronization.mutex_concepts.timed_lockable.timed_lock_duration `timed_lock`]]
[template lock_shared_ref_link[link_text] [link thread.synchronization.mutex_concepts.shared_lockable.lock_shared [link_text]]]
[def __lock_shared_ref__ [lock_shared_ref_link `lock_shared()`]]
[def __lock_shared [link thread.synchronization.mutex_concepts.shared_lockable.lock_shared `lock_shared()`]]
[template unlock_shared_ref_link[link_text] [link thread.synchronization.mutex_concepts.shared_lockable.unlock_shared [link_text]]]
[def __unlock_shared_ref__ [unlock_shared_ref_link `unlock_shared()`]]
[def __unlock_shared [link thread.synchronization.mutex_concepts.shared_lockable.unlock_shared `unlock_shared()`]]
[template try_lock_shared_ref_link[link_text] [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared [link_text]]]
[def __try_lock_shared_ref__ [try_lock_shared_ref_link `try_lock_shared()`]]
[def __try_lock_shared [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared `try_lock_shared`]]
[template timed_lock_shared_ref_link[link_text] [link thread.synchronization.mutex_concepts.shared_lockable.timed_lock_shared [link_text]]]
[def __timed_lock_shared_ref__ [timed_lock_shared_ref_link `timed_lock_shared()`]]
[def __try_lock_shared_for [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared_for `try_lock_shared_for`]]
[def __try_lock_shared_for [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared_until `try_lock_shared_until`]]
[template timed_lock_shared_duration_ref_link[link_text] [link thread.synchronization.mutex_concepts.shared_lockable.timed_lock_shared_duration [link_text]]]
[def __timed_lock_shared_duration_ref__ [timed_lock_shared_duration_ref_link `timed_lock_shared()`]]
[def __try_lock_shared_for [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared_for `try_lock_shared_for`]]
[def __try_lock_shared_until [link thread.synchronization.mutex_concepts.shared_lockable.try_lock_shared_until `try_lock_shared_until`]]
[template lock_upgrade_ref_link[link_text] [link thread.synchronization.mutex_concepts.upgrade_lockable.lock_upgrade [link_text]]]
[def __lock_upgrade_ref__ [lock_upgrade_ref_link `lock_upgrade()`]]
[def __lock_upgrade [link thread.synchronization.mutex_concepts.upgrade_lockable.lock_upgrade `lock_upgrade`]]
[def __try_lock_upgrade [link thread.synchronization.mutex_concepts.upgrade_lockable.try_lock_upgrade `try_lock_upgrade`]]
[def __try_lock_upgrade_for [link thread.synchronization.mutex_concepts.upgrade_lockable.try_lock_upgrade_for `try_lock_upgrade_for`]]
[def __try_lock_upgrade_until [link thread.synchronization.mutex_concepts.upgrade_lockable.try_lock_upgrade_until `try_lock_upgrade_until`]]
[template unlock_upgrade_ref_link[link_text] [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade [link_text]]]
[def __unlock_upgrade_ref__ [unlock_upgrade_ref_link `unlock_upgrade()`]]
[def __unlock_upgrade [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade `unlock_upgrade`]]
[template unlock_upgrade_and_lock_ref_link[link_text] [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade_and_lock [link_text]]]
[def __unlock_upgrade_and_lock_ref__ [unlock_upgrade_and_lock_ref_link `unlock_upgrade_and_lock()`]]
[def __unlock_upgrade_and_lock [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade_and_lock `unlock_upgrade_and_lock`]]
[template unlock_and_lock_upgrade_ref_link[link_text] [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_and_lock_upgrade [link_text]]]
[def __unlock_and_lock_upgrade_ref__ [unlock_and_lock_upgrade_ref_link `unlock_and_lock_upgrade()`]]
[def __unlock_and_lock_upgrade [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_and_lock_upgrade `unlock_and_lock_upgrade`]]
[template unlock_upgrade_and_lock_shared_ref_link[link_text] [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade_and_lock_shared [link_text]]]
[def __unlock_upgrade_and_lock_shared_ref__ [unlock_upgrade_and_lock_shared_ref_link `unlock_upgrade_and_lock_shared()`]]
[def __unlock_upgrade_and_lock_shared [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_upgrade_and_lock_shared `unlock_upgrade_and_lock_shared`]]
[def __try_unlock_shared_and_lock [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock `try_unlock_shared_and_lock`]]
[def __try_unlock_shared_and_lock_for [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock_for `try_unlock_shared_and_lock_for`]]
[def __try_unlock_shared_and_lock_until [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock_until `try_unlock_shared_and_lock_until`]]
[def __unlock_and_lock_shared [link thread.synchronization.mutex_concepts.upgrade_lockable.unlock_and_lock_shared `unlock_and_lock_shared`]]
[def __try_unlock_shared_and_lock_upgrade [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock_upgrade `try_unlock_shared_and_lock_upgrade`]]
[def __try_unlock_shared_and_lock_upgrade_for [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock_upgrade_for `try_unlock_shared_and_lock_upgrade_for`]]
[def __try_unlock_shared_and_lock_upgrade_until [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_shared_and_lock_upgrade_until `try_unlock_shared_and_lock_upgrade_until`]]
[def __try_unlock_upgrade_and_lock [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_upgrade_and_lock `try_unlock_upgrade_and_lock`]]
[def __try_unlock_upgrade_and_lock_for [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_upgrade_and_lock_for `try_unlock_upgrade_and_lock_for`]]
[def __try_unlock_upgrade_and_lock_until [link thread.synchronization.mutex_concepts.upgrade_lockable.try_unlock_upgrade_and_lock_until `try_unlock_upgrade_and_lock_until`]]
[template owns_lock_ref_link[link_text] [link thread.synchronization.locks.unique_lock.owns_lock [link_text]]]
[def __owns_lock_ref__ [owns_lock_ref_link `owns_lock()`]]
[def __owns_lock [owns_lock_ref_link `owns_lock()`]]
[template owns_lock_shared_ref_link[link_text] [link thread.synchronization.locks.shared_lock.owns_lock [link_text]]]
[def __owns_lock_shared_ref__ [owns_lock_shared_ref_link `owns_lock()`]]
@@ -98,6 +146,7 @@
[def __boost_thread__ [*Boost.Thread]]
[def __not_a_thread__ ['Not-a-Thread]]
[def __interruption_points__ [link interruption_points ['interruption points]]]
[def __lock_error__ `lock_error`]
[def __mutex__ [link thread.synchronization.mutex_types.mutex `boost::mutex`]]
[def __try_mutex__ [link thread.synchronization.mutex_types.try_mutex `boost::try_mutex`]]
@@ -107,24 +156,43 @@
[def __recursive_timed_mutex__ [link thread.synchronization.mutex_types.recursive_timed_mutex `boost::recursive_timed_mutex`]]
[def __shared_mutex__ [link thread.synchronization.mutex_types.shared_mutex `boost::shared_mutex`]]
[def __StrictLock [link thread.synchronization.lock_concepts.StrictLock `StrictLock`]]
[template unique_lock_link[link_text] [link thread.synchronization.locks.unique_lock [link_text]]]
[def __lock_guard__ [link thread.synchronization.locks.lock_guard `boost::lock_guard`]]
[def __lock_guard__ [link thread.synchronization.lock_guard.lock_guard `boost::lock_guard`]]
[def __unique_lock__ [unique_lock_link `boost::unique_lock`]]
[def __unique_lock [unique_lock_link `boost::unique_lock`]]
[def __shared_lock__ [link thread.synchronization.locks.shared_lock `boost::shared_lock`]]
[def __upgrade_lock__ [link thread.synchronization.locks.upgrade_lock `boost::upgrade_lock`]]
[def __upgrade_to_unique_lock__ [link thread.synchronization.locks.upgrade_to_unique_lock `boost::upgrade_to_unique_lock`]]
[def __reverse_lock [link thread.synchronization.other_locks.reverse_lock `reverse_lock`]]
[def __shared_lock_guard [link thread.synchronization.other_locks.shared_lock_guard `shared_lock_guard`]]
[def __shared_lock_guard_constructor_adopt [link thread.synchronization.other_locks.shared_lock_guard `shared_lock_guard`]]
[def __strict_lock [link thread.synchronization.other_locks.strict_locks.strict_lock `strict_lock`]]
[def __nested_strict_lock [link thread.synchronization.other_locks.strict_locks.nested_strict_lock `nested_strict_lock`]]
[def __thread__ [link thread.thread_management.thread `boost::thread`]]
[def __thread [link thread.thread_management.thread `thread`]]
[def __thread_id__ [link thread.thread_management.thread.id `boost::thread::id`]]
[template join_link[link_text] [link thread.thread_management.thread.join [link_text]]]
[def __join__ [join_link `join()`]]
[def __try_join_for [link thread.thread_management.thread.try_join_for `try_join_for`]]
[def __try_join_until [link thread.thread_management.thread.try_join_until `try_join_until`]]
[template timed_join_link[link_text] [link thread.thread_management.thread.timed_join [link_text]]]
[def __timed_join__ [timed_join_link `timed_join()`]]
[def __detach__ [link thread.thread_management.thread.detach `detach()`]]
[def __interrupt__ [link thread.thread_management.thread.interrupt `interrupt()`]]
[def __sleep__ [link thread.thread_management.this_thread.sleep `boost::this_thread::sleep()`]]
[def __sleep_for [link thread.thread_management.this_thread.sleep_for `sleep_for`]]
[def __sleep_until [link thread.thread_management.this_thread.sleep_until `sleep_until`]]
[def __yield [link thread.thread_management.this_thread.yield `yield`]]
[def __get_id [link thread.thread_management.thread.get_id `get_id`]]
[def __interruption_enabled__ [link thread.thread_management.this_thread.interruption_enabled `boost::this_thread::interruption_enabled()`]]
[def __interruption_requested__ [link thread.thread_management.this_thread.interruption_requested `boost::this_thread::interruption_requested()`]]
@@ -135,34 +203,61 @@
[def __thread_resource_error__ `boost::thread_resource_error`]
[def __thread_interrupted__ `boost::thread_interrupted`]
[def __barrier__ [link thread.synchronization.barriers.barrier `boost::barrier`]]
[def __latch__ [link thread.synchronization.latches.latch `latch`]]
[template cond_wait_link[link_text] [link thread.synchronization.condvar_ref.condition_variable.wait [link_text]]]
[def __cond_wait__ [cond_wait_link `wait()`]]
[template cond_timed_wait_link[link_text] [link thread.synchronization.condvar_ref.condition_variable.timed_wait [link_text]]]
[def __cond_timed_wait__ [cond_timed_wait_link `timed_wait()`]]
[def __condition_variable [link thread.synchronization.condvar_ref.condition_variable `condition_variable`]]
[def __wait_for [link thread.synchronization.condvar_ref.condition_variable.wait_for `wait_for`]]
[def __wait_until [link thread.synchronization.condvar_ref.condition_variable.wait_until `wait_until`]]
[template cond_any_wait_link[link_text] [link thread.synchronization.condvar_ref.condition_variable_any.wait [link_text]]]
[def __cond_any_wait__ [cond_any_wait_link `wait()`]]
[template cond_any_timed_wait_link[link_text] [link thread.synchronization.condvar_ref.condition_variable_any.timed_wait [link_text]]]
[def __cond_any_timed_wait__ [cond_any_timed_wait_link `timed_wait()`]]
[def __condition_variable_any [link thread.synchronization.condvar_ref.condition_variable_any `condition_variable_any`]]
[def __cvany_wait_for [link thread.synchronization.condvar_ref.condition_variable_any.wait_for `wait_for`]]
[def __cvany_wait_until [link thread.synchronization.condvar_ref.condition_variable_any.wait_until `wait_until`]]
[def __blocked__ ['blocked]]
[include overview.qbk]
[include changes.qbk]
[include thread_ref.qbk]
[include scoped_thread.qbk]
[section:synchronization Synchronization]
[include sync_tutorial.qbk]
[include mutex_concepts.qbk]
[include mutexes.qbk]
[include condition_variables.qbk]
[include once.qbk]
[include barrier.qbk]
[include latch.qbk]
[include async_executors.qbk]
[include futures.qbk]
[endsect]
[include tss.qbk]
[section:sds Synchronized Data Structures]
[include synchronized_value.qbk]
[include sync_queues_ref.qbk]
[/include sync_streams.qbk]
[endsect]
[include parallel.qbk]
[include time.qbk]
[include emulations.qbk]
[include acknowledgements.qbk]
[include compliance.qbk]

File diff suppressed because it is too large Load Diff

View File

@@ -5,19 +5,33 @@
http://www.boost.org/LICENSE_1_0.txt).
]
[section:time Date and Time Requirements]
[section:time Time Requirements]
As of Boost 1.35.0, the __boost_thread__ library uses the [link date_time Boost.Date_Time] library for all operations that require a
time out. These include (but are not limited to):
As of Boost 1.50.0, the __boost_thread__ library uses Boost.Chrono library for all operations that require a
time out as defined in the standard c++11. These include (but are not limited to):
* `boost::this_thread::__sleep_for`
* `boost::this_thread::__sleep_until`
* `boost::__thread::__try_join_for`
* `boost::__thread::__try_join_until`
* `boost::__condition_variable::__wait_for`
* `boost::__condition_variable::__wait_until`
* `boost::__condition_variable_any::__cvany_wait_for`
* `boost::__condition_variable_any::__cvany_wait_until`
* `__TimedLockable::__try_lock_for`
* `__TimedLockable::__try_lock_until`
[section:deprecated Deprecated]
The time related functions introduced in Boost 1.35.0, using the [link date_time Boost.Date_Time] library are deprecated. These include (but are not limited to):
* __sleep__
* __timed_join__
* __cond_timed_wait__
* __timed_lock_ref__
For the overloads that accept an absolute time parameter, an object of type [link thread.time.system_time `boost::system_time`] is
For the overloads that accept an absolute time parameter, an object of type [link thread.time.deprecated.system_time `boost::system_time`] is
required. Typically, this will be obtained by adding a duration to the current time, obtained with a call to [link
thread.time.get_system_time `boost::get_system_time()`]. e.g.
thread.time.deprecated.get_system_time `boost::get_system_time()`]. e.g.
boost::system_time const timeout=boost::get_system_time() + boost::posix_time::milliseconds(500);
@@ -70,6 +84,7 @@ See the documentation for [link date_time.posix_time.ptime_class `boost::posix_t
]
[endsect]
[endsect]
[endsect]

View File

@@ -41,11 +41,22 @@ order. If a cleanup routine sets the value of associated with an instance of `bo
cleaned up, that value is added to the cleanup list. Cleanup finishes when there are no outstanding instances of
`boost::thread_specific_ptr` with values.
Note: on some platforms, cleanup of thread-specific data is not
performed for threads created with the platform's native API. On those
platforms such cleanup is only done for threads that are started with
`boost::thread` unless `boost::on_thread_exit()` is called manually
from that thread.
[heading Rationale about the nature of the key]
Boost.Thread uses the address of the `thread_specific_ptr` instance as key of the thread specific pointers. This avoids to create/destroy a key which will need a lock to protect from race conditions. This has a little performance liability, as the access must be done using an associative container.
[section:thread_specific_ptr Class `thread_specific_ptr`]
#include <boost/thread/tss.hpp>
// #include <boost/thread/tss.hpp>
namespace boost
{
template <typename T>
class thread_specific_ptr
{
@@ -61,6 +72,7 @@ cleaned up, that value is added to the cleanup list. Cleanup finishes when there
T* release();
void reset(T* new_value=0);
};
}
[section:default_constructor `thread_specific_ptr();`]
@@ -97,10 +109,14 @@ supplied `cleanup_function` will be used to destroy any thread-local objects whe
[variablelist
[[Requires:] [All the thread specific instances associated to this thread_specific_ptr (except maybe the one associated to this thread) must be null.]]
[[Effects:] [Calls `this->reset()` to clean up the associated value for the current thread, and destroys `*this`.]]
[[Throws:] [Nothing.]]
[[Remarks:] [The requirement is due to the fact that in order to delete all these instances, the implementation should be forced to maintain a list of all the threads having an associated specific ptr, which is against the goal of thread specific data.]]
]
[note Care needs to be taken to ensure that any threads still running after an instance of `boost::thread_specific_ptr` has been

View File

@@ -0,0 +1,116 @@
// Copyright (C) 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 4
#include <boost/thread/mutex.hpp>
#include <boost/thread/lockable_adapter.hpp>
#include <boost/thread/externally_locked.hpp>
#include <boost/thread/strict_lock.hpp>
#include <boost/thread/lock_types.hpp>
#include <iostream>
using namespace boost;
class BankAccount
{
int balance_;
public:
void Deposit(int amount)
{
balance_ += amount;
}
void Withdraw(int amount)
{
balance_ -= amount;
}
int GetBalance()
{
return balance_;
}
};
//[AccountManager
class AccountManager: public basic_lockable_adapter<mutex>
{
public:
typedef basic_lockable_adapter<mutex> lockable_base_type;
AccountManager() :
lockable_base_type(), checkingAcct_(*this), savingsAcct_(*this)
{
}
inline void Checking2Savings(int amount);
inline void AMoreComplicatedChecking2Savings(int amount);
private:
/*<-*/
bool some_condition()
{
return true;
} /*->*/
externally_locked<BankAccount, AccountManager > checkingAcct_;
externally_locked<BankAccount, AccountManager > savingsAcct_;
};
//]
//[Checking2Savings
void AccountManager::Checking2Savings(int amount)
{
strict_lock<AccountManager> guard(*this);
checkingAcct_.get(guard).Withdraw(amount);
savingsAcct_.get(guard).Deposit(amount);
}
//]
//#if DO_NOT_COMPILE
////[AMoreComplicatedChecking2Savings_DO_NOT_COMPILE
//void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
// unique_lock<AccountManager> guard(*this);
// if (some_condition()) {
// guard.lock();
// }
// checkingAcct_.get(guard).Withdraw(amount);
// savingsAcct_.get(guard).Deposit(amount);
// guard1.unlock();
//}
////]
//#elif DO_NOT_COMPILE_2
////[AMoreComplicatedChecking2Savings_DO_NOT_COMPILE2
//void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
// unique_lock<AccountManager> guard1(*this);
// if (some_condition()) {
// guard1.lock();
// }
// {
// strict_lock<AccountManager> guard(guard1);
// checkingAcct_.get(guard).Withdraw(amount);
// savingsAcct_.get(guard).Deposit(amount);
// }
// guard1.unlock();
//}
////]
//#else
////[AMoreComplicatedChecking2Savings
void AccountManager::AMoreComplicatedChecking2Savings(int amount) {
unique_lock<AccountManager> guard1(*this);
if (some_condition()) {
guard1.lock();
}
{
nested_strict_lock<unique_lock<AccountManager> > guard(guard1);
checkingAcct_.get(guard).Withdraw(amount);
savingsAcct_.get(guard).Deposit(amount);
}
guard1.unlock();
}
////]
//#endif
int main()
{
AccountManager mgr;
mgr.Checking2Savings(100);
return 0;
}

View File

@@ -1,21 +1,22 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <vector>
#include <boost/utility.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/thread_only.hpp>
#include "../test/remove_error_code_unused_warning.hpp"
class bounded_buffer : private boost::noncopyable
{
public:
typedef boost::mutex::scoped_lock lock;
typedef boost::unique_lock<boost::mutex> lock;
bounded_buffer(int n) : begin(0), end(0), buffered(0), circular_buf(n) { }
bounded_buffer(int n) : boost::noncopyable(), begin(0), end(0), buffered(0), circular_buf(n) { }
void send (int m) {
lock lk(monitor);
@@ -38,9 +39,10 @@ public:
}
private:
int begin, end, buffered;
int begin, end;
std::vector<int>::size_type buffered;
std::vector<int> circular_buf;
boost::condition buffer_not_full, buffer_not_empty;
boost::condition_variable_any buffer_not_full, buffer_not_empty;
boost::mutex monitor;
};
@@ -54,7 +56,7 @@ void sender() {
buf.send(n);
if(!(n%10000))
{
boost::mutex::scoped_lock io_lock(io_mutex);
boost::unique_lock<boost::mutex> io_lock(io_mutex);
std::cout << "sent: " << n << std::endl;
}
++n;
@@ -68,7 +70,7 @@ void receiver() {
n = buf.receive();
if(!(n%10000))
{
boost::mutex::scoped_lock io_lock(io_mutex);
boost::unique_lock<boost::mutex> io_lock(io_mutex);
std::cout << "received: " << n << std::endl;
}
} while (n != -1); // -1 indicates end of buffer

View File

@@ -0,0 +1,61 @@
// Copyright (C) 2014 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/generic_executor_ref.hpp>
#include <string>
#include <iostream>
#include <boost/thread/caller_context.hpp>
boost::generic_executor_ref default_executor()
{
static boost::basic_thread_pool tp(4);
return boost::generic_executor_ref(tp);
}
void p2()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
std::cout << BOOST_CONTEXTOF << std::endl;
}
void p1()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
default_executor().submit(&p2);
boost::this_thread::sleep_for(boost::chrono::milliseconds(400));
std::cout << BOOST_CONTEXTOF << std::endl;
}
int main()
{
std::cout << BOOST_CONTEXTOF << std::endl;
default_executor().submit(&p1);
boost::this_thread::sleep_for(boost::chrono::seconds(5));
std::cout << BOOST_CONTEXTOF << std::endl;
return 1;
}

207
example/executor.cpp Normal file
View File

@@ -0,0 +1,207 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <iostream>
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/loop_executor.hpp>
#include <boost/thread/executors/serial_executor.hpp>
#include <boost/thread/executors/inline_executor.hpp>
#include <boost/thread/executors/thread_executor.hpp>
#include <boost/thread/executors/executor.hpp>
#include <boost/thread/executors/executor_adaptor.hpp>
#include <boost/thread/executor.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
#include <cassert>
boost::future<void> p(boost::future<void> f) {
assert(f.is_ready());
return boost::make_ready_future();
}
void p1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
//boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
}
void p2()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
//boost::this_thread::sleep_for(boost::chrono::seconds(10));
}
int f1()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
std::cout << BOOST_CONTEXTOF << std::endl;
return 1;
}
int f2(int i)
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(2));
return i + 1;
}
void submit_some(boost::executor& tp)
{
for (int i = 0; i < 3; ++i) {
tp.submit(&p2);
}
for (int i = 0; i < 3; ++i) {
tp.submit(&p1);
}
}
void at_th_entry(boost::basic_thread_pool& )
{
}
int test_executor_adaptor()
{
std::cout << BOOST_CONTEXTOF << std::endl;
{
try
{
{
boost::executor_adaptor < boost::basic_thread_pool > ea(4);
std::cout << BOOST_CONTEXTOF << std::endl;
submit_some( ea);
std::cout << BOOST_CONTEXTOF << std::endl;
#if 1
// fixme
// ERROR= tr1::bad_weak_ptr
{
boost::future<int> t1 = boost::async(ea, &f1);
boost::future<int> t2 = boost::async(ea, &f1);
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl;
}
std::cout << BOOST_CONTEXTOF << std::endl;
submit_some(ea);
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea3(1);
std::cout << BOOST_CONTEXTOF << std::endl;
boost::future<int> t1 = boost::async(ea3, &f1);
std::cout << BOOST_CONTEXTOF << std::endl;
boost::future<int> t2 = boost::async(ea3, &f1);
std::cout << BOOST_CONTEXTOF << std::endl;
//boost::future<int> t2 = boost::async(ea3, f2, 1); // todo this doesn't compiles yet on C++11
//boost::future<int> t2 = boost::async(ea3, boost::bind(f2, 1)); // todo this doesn't compiles yet on C++98
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl;
}
#endif
std::cout << BOOST_CONTEXTOF << std::endl;
submit_some(ea);
std::cout << BOOST_CONTEXTOF << std::endl;
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::executor_adaptor < boost::loop_executor > ea2;
submit_some( ea2);
ea2.underlying_executor().run_queued_closures();
}
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::executor_adaptor < boost::basic_thread_pool > ea1(4);
boost::executor_adaptor < boost::serial_executor > ea2(ea1);
submit_some(ea2);
}
#endif
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::executor_adaptor < boost::inline_executor > ea1;
submit_some(ea1);
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::executor_adaptor < boost::thread_executor > ea1;
submit_some(ea1);
}
std::cout << BOOST_CONTEXTOF << std::endl;
#if 1
// fixme
// ERROR= tr1::bad_weak_ptr
{
boost::basic_thread_pool ea(4, at_th_entry);
boost::future<int> t1 = boost::async(ea, &f1);
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
}
#endif
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::async(&f1);
}
#if 1
// fixme
// ERROR= tr1::bad_weak_ptr
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea(1);
boost::async(ea,&f1);
}
#endif
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
std::cout << BOOST_CONTEXTOF << std::endl;
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
}
// std::cout << BOOST_CONTEXTOF << std::endl;
return 0;
}
int main()
{
return test_executor_adaptor();
#if 0 && defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \
&& defined BOOST_THREAD_PROVIDES_EXECUTORS \
&& ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
boost::basic_thread_pool executor;
// compiles
boost::make_ready_future().then(&p);
// ??
boost::make_ready_future().then(executor, &p);
// doesn't compile
boost::make_ready_future().then(executor, &p);
#endif
}

View File

@@ -0,0 +1,91 @@
// Copyright (C) 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#include <boost/thread/experimental/task_region.hpp>
#include <iostream>
#if ! defined BOOST_NO_CXX11_RANGE_BASED_FOR && ! defined BOOST_NO_CXX11_LAMBDAS
int fib_task_region(int n)
{
using boost::experimental::parallel::task_region;
using boost::experimental::parallel::task_region_handle;
if (n == 0) return 0;
if (n == 1) return 1;
int n1;
int n2;
task_region([&](task_region_handle& trh)
{
trh.run([&]
{
n1 = fib_task_region(n - 1);
});
n2 = fib_task_region(n - 2);
});
return n1 + n2;
}
#if defined BOOST_THREAD_PROVIDES_EXECUTORS
template <class Ex>
int fib_task_region_gen( Ex& ex, int n)
{
using boost::experimental::parallel::task_region;
using boost::experimental::parallel::task_region_handle_gen;
if (n == 0) return 0;
if (n == 1) return 1;
int n1;
int n2;
task_region(ex, [&](task_region_handle_gen<Ex>& trh)
{
trh.run([&]
{
n1 = fib_task_region(n - 1);
});
n2 = fib_task_region(n - 2);
});
return n1 + n2;
}
#endif
int main()
{
for (int i = 0; i<10; ++i) {
std::cout << fib_task_region(i) << " ";
}
std::cout << std::endl;
#if defined BOOST_THREAD_PROVIDES_EXECUTORS
boost::basic_thread_pool tp;
for (int i = 0; i<10; ++i) {
std::cout << fib_task_region_gen(tp,i) << " ";
}
std::cout << std::endl;
#endif
return 0;
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,157 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/detail/log.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <exception>
#include <string>
#include <iostream>
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
int p1_ex()
{
BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
throw std::logic_error("kk");
}
int p1()
{
BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
return 1;;
}
int main()
{
const int number_of_tests = 200;
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
f1.wait();
BOOST_ASSERT(f1.get()==1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(&p1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.fallback_to(-1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
f2.wait();
//std::cout << __FILE__ << "["<< __LINE__<<"] " << std::endl;
BOOST_ASSERT(f2.get()==1);
//std::cout << __FILE__ << "["<< __LINE__<<"] " << std::endl;
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1_ex);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
f1.wait();
BOOST_ASSERT(f1.get_or(-1)==-1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1_ex);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.fallback_to(-1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
f2.wait();
//std::cout << __FILE__ << "["<< __LINE__<<"] " << std::endl;
BOOST_ASSERT(f2.get()==-1);
//std::cout << __FILE__ << "["<< __LINE__<<"] " << std::endl;
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << __FILE__ << "["<< __LINE__<<"] " << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}
#else
int main()
{
return 0;
}
#endif

133
example/future_then.cpp Normal file
View File

@@ -0,0 +1,133 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/detail/log.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
int p1()
{
BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
return 123;
}
int p2(boost::future<int> f)
{
BOOST_THREAD_LOG << "P2<" << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
catch (...)
{
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG;
return 0;
}
int p2s(boost::shared_future<int> f)
{
BOOST_THREAD_LOG << "<P2S" << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
catch (...)
{
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
BOOST_THREAD_LOG << "P2S>" << BOOST_THREAD_END_LOG;
return 0;
}
int main()
{
const int number_of_tests = 100;
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(&p1);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.then(&p2);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
(void)f2.get();
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
{
for (int i=0; i< number_of_tests; i++)
try
{
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::shared_future<int> f1 = boost::async(&p1).share();
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.then(&p2s);
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
(void)f2.get();
BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}
#else
int main()
{
return 0;
}
#endif

88
example/future_unwrap.cpp Normal file
View File

@@ -0,0 +1,88 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/detail/log.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
int p1()
{
BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
return 123;
}
boost::future<int> p2()
{
BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG;
return boost::move(f1);
}
int main()
{
const int number_of_tests = 100;
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
for (int i=0; i< number_of_tests; i++)
try
{
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
boost::future<int> inner_future = boost::async(boost::launch::async, &p2).unwrap();
inner_future.wait();
int ii = inner_future.get();
BOOST_THREAD_LOG << "ii= "<< ii << "" << BOOST_THREAD_END_LOG;
}
#endif
{
boost::future<boost::future<int> > outer_future = boost::async(boost::launch::async, &p2);
boost::future<int> inner_future = outer_future.unwrap();
inner_future.wait();
int ii = inner_future.get();
BOOST_THREAD_LOG << "ii= "<< ii << "" << BOOST_THREAD_END_LOG;
}
{
boost::future<boost::future<int> > outer_future = boost::async(boost::launch::async, &p2);
boost::future<int> inner_future = outer_future.unwrap();
int ii = inner_future.get();
BOOST_THREAD_LOG << "ii= "<< ii << "" << BOOST_THREAD_END_LOG;
}
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}
#else
int main()
{
return 0;
}
#endif

326
example/future_when_all.cpp Normal file
View File

@@ -0,0 +1,326 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/future.hpp>
#include <boost/thread/csbl/vector.hpp>
#include <boost/assert.hpp>
#include <boost/thread/detail/log.hpp>
#include <string>
#if defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
int p1()
{
BOOST_THREAD_LOG
<< "P1" << BOOST_THREAD_END_LOG;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
return 123;
}
int p1b()
{
BOOST_THREAD_LOG
<< "P1b" << BOOST_THREAD_END_LOG;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
return 321;
}
int p2(boost::future<int> f)
{
BOOST_THREAD_LOG
<< " P2 " << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
BOOST_THREAD_LOG
<< "P2>" << BOOST_THREAD_END_LOG;
return 0;
}
int p2s(boost::shared_future<int> f)
{
BOOST_THREAD_LOG
<< "<P2" << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
BOOST_THREAD_LOG
<< "P2>" << BOOST_THREAD_END_LOG;
return 0;
}
int main()
{
BOOST_THREAD_LOG
<< "<MAIN" << BOOST_THREAD_END_LOG;
{
try
{
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<boost::csbl::tuple<> > all0 = boost::when_all();
BOOST_THREAD_LOG
<< BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<boost::csbl::tuple<boost::future<int> > > all = boost::when_all(boost::move(f1));
boost::csbl::tuple<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<boost::csbl::tuple<boost::future<int> > > all = boost::when_all(boost::move(f1));
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::csbl::tuple<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#endif
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::make_ready_future(1);
boost::future<boost::csbl::tuple<boost::future<int> > > all = boost::when_all(boost::move(f1));
boost::csbl::tuple<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<int> f2 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_all(boost::move(f1), boost::move(f2));
//(void) all.wait();
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<std::string> f2 = boost::make_ready_future(std::string("nnnnnnn"));;
boost::future<boost::csbl::tuple<boost::future<int>, boost::future<std::string> > > all = boost::when_all(boost::move(f1), boost::move(f2));
//(void) all.wait();
boost::csbl::tuple<boost::future<int>, boost::future<std::string> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::csbl::vector<boost::future<int> > v;
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
v.push_back(boost::async(boost::launch::async, &p1));
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
v.push_back(boost::async(boost::launch::async, &p1b));
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_all(v.begin(), v.end());
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::csbl::vector<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< res[0].get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< res[1].get() <<" " << BOOST_THREAD_END_LOG;
}
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
{
try
{
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<boost::csbl::tuple<> > all0 = boost::when_any();
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<boost::csbl::tuple<boost::future<int> > > all = boost::when_any(boost::move(f1));
boost::csbl::tuple<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
boost::future<boost::csbl::tuple<boost::future<int> > > all = boost::when_any(boost::move(f1));
boost::csbl::tuple<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#endif
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<int> f2 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::make_ready_future(1);
boost::future<int> f2 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<std::string> f1 = boost::make_ready_future(std::string("aaaa"));
boost::future<int> f2 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<std::string>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<std::string>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f2 = boost::make_ready_future(1);
boost::future<int> f1 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
boost::future<int> f2 = boost::async(boost::launch::async, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
boost::future<int> f2 = boost::async(boost::launch::deferred, &p1b);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
boost::csbl::tuple<boost::future<int>,boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< boost::csbl::get<0>(res).get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< boost::csbl::get<1>(res).get() <<" " << BOOST_THREAD_END_LOG;
}
#endif
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::csbl::vector<boost::future<int> > v;
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
v.push_back(boost::async(boost::launch::async, &p1));
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
v.push_back(boost::async(boost::launch::async, &p1b));
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_any(v.begin(), v.end());
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
boost::csbl::vector<boost::future<int> > res = all.get();
BOOST_THREAD_LOG
<< res[0].get() <<" " << BOOST_THREAD_END_LOG;
BOOST_THREAD_LOG
<< res[1].get() <<" " << BOOST_THREAD_END_LOG;
}
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
BOOST_THREAD_LOG
<< "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}
#else
#include <boost/thread/csbl/vector.hpp>
using namespace boost;
void f( boost::csbl::vector<future<int> > &//vec
, BOOST_THREAD_RV_REF(future<int>) //f
) {
}
int main()
{
boost::csbl::vector<future<int> > vec;
f(vec, make_ready_future(0));
return 0;
}
#endif

View File

@@ -0,0 +1,163 @@
// Copyright (C) 2014 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/loop_executor.hpp>
#include <boost/thread/executors/serial_executor.hpp>
#include <boost/thread/executors/inline_executor.hpp>
#include <boost/thread/executors/thread_executor.hpp>
#include <boost/thread/executors/executor.hpp>
#include <boost/thread/executors/executor_adaptor.hpp>
#include <boost/thread/executor.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
void p1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
//boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
}
void p2()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
//boost::this_thread::sleep_for(boost::chrono::seconds(10));
}
int f1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
return 1;
}
int f2(int i)
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(2));
return i + 1;
}
void submit_some(boost::generic_executor_ref tp)
{
for (int i = 0; i < 3; ++i) {
tp.submit(&p2);
}
for (int i = 0; i < 3; ++i) {
tp.submit(&p1);
}
}
void at_th_entry(boost::basic_thread_pool& )
{
}
int test_generic_executor_ref()
{
std::cout << BOOST_CONTEXTOF << std::endl;
{
try
{
{
boost::basic_thread_pool ea(4);
submit_some( ea);
{
boost::future<int> t1 = boost::async(ea, &f1);
boost::future<int> t2 = boost::async(ea, &f1);
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl;
}
submit_some(ea);
{
boost::basic_thread_pool ea3(1);
boost::future<int> t1 = boost::async(ea3, &f1);
boost::future<int> t2 = boost::async(ea3, &f1);
//boost::future<int> t2 = boost::async(ea3, f2, 1); // todo this doesn't compiles yet on C++11
//boost::future<int> t2 = boost::async(ea3, boost::bind(f2, 1)); // todo this doesn't compiles yet on C++98
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl;
}
submit_some(ea);
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::loop_executor ea2;
submit_some( ea2);
ea2.run_queued_closures();
}
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea1(4);
boost::serial_executor ea2(ea1);
submit_some(ea2);
}
#endif
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::inline_executor ea1;
submit_some(ea1);
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
//boost::thread_executor ea1;
//submit_some(ea1);
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea(4, at_th_entry);
boost::future<int> t1 = boost::async(ea, &f1);
std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl;
}
std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea(4, at_th_entry);
boost::async(ea, &f1);
std::cout << BOOST_CONTEXTOF << std::endl;
}
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
std::cout << BOOST_CONTEXTOF << std::endl;
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
}
// std::cout << BOOST_CONTEXTOF << std::endl;
return 0;
}
int main()
{
return test_generic_executor_ref();
}

75
example/lambda_future.cpp Normal file
View File

@@ -0,0 +1,75 @@
// Copyright (C) 2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/detail/log.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \
&& ! defined BOOST_NO_CXX11_LAMBDAS && ! (defined BOOST_MSVC && _MSC_VER < 1700)
int main()
{
const int number_of_tests = 100;
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
for (int i=0; i< number_of_tests; i++)
try
{
{
boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;});
int result = f1.get();
BOOST_THREAD_LOG << "f1 " << result << BOOST_THREAD_END_LOG;
}
{
boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;});
boost::future<int> f2 = f1.then([](boost::future<int> f) {return 2*f.get(); });
int result = f2.get();
BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG;
}
#if ! defined BOOST_NO_CXX14_GENERIC_LAMBDAS
{
boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;});
boost::future<int> f2 = f1.then([](auto f) {return 2*f.get(); });
int result = f2.get();
BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG;
}
#endif
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
std::cout << " ERRORRRRR exception thrown" << std::endl;
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}
#else
int main()
{
return 0;
}
#endif

154
example/make_future.cpp Normal file
View File

@@ -0,0 +1,154 @@
// Copyright (C) 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#include <boost/thread/future.hpp>
#include <iostream>
namespace boost
{
template <typename T>
exception_ptr make_exception_ptr(T v)
{
return copy_exception(v);
}
}
int p1() { return 5; }
int& p1r() { static int i=0; return i; }
void p() { }
#if defined BOOST_THREAD_USES_MOVE
boost::future<void> void_compute()
{
return BOOST_THREAD_MAKE_RV_REF(boost::make_ready_future());
}
#endif
boost::future<int> compute(int x)
{
if (x == 0) return boost::make_ready_future(0);
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
if (x < 0) return boost::make_exceptional_future<int>(std::logic_error("Error"));
#else
if (x < 0) return boost::make_exceptional(std::logic_error("Error"));
#endif
//boost::future<int> f1 = boost::async([]() { return x+1; });
boost::future<int> f1 = boost::async(p1);
return boost::move(f1);
}
boost::future<int&> compute_ref(int x)
{
static int i = 0;
//if (x == 0) return boost::make_ready_future<int&>(i); //This must not compile as the type is deduced as boost::future<int>
if (x == 0) return boost::make_ready_no_decay_future<int&>(i);
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
if (x < 0) return boost::make_exceptional_future<int&>(std::logic_error("Error"));
#else
if (x < 0) return boost::make_exceptional(std::logic_error("Error"));
#endif
boost::future<int&> f1 = boost::async(p1r);
return boost::move(f1);
}
boost::shared_future<int> shared_compute(int x)
{
if (x == 0) return boost::make_ready_future(0).share();
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
if (x < 0) return boost::make_exceptional_future<int>(std::logic_error("Error")).share();
#else
if (x < 0) return boost::make_exceptional(std::logic_error("Error"));
#endif
//boost::future<int> f1 = boost::async([]() { return x+1; });
boost::shared_future<int> f1 = boost::async(&p1).share();
return f1;
}
int main()
{
const int number_of_tests = 100;
for (int i=0; i< number_of_tests; i++)
try
{
// {
// std::cout << __FILE__ << " "<<__LINE__ << std::endl;
// boost::future<int> f = boost::async(boost::launch::async, p1);
// std::cout << i << " "<<f.get() << std::endl;
// }
#if defined BOOST_THREAD_USES_MOVE
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<void> f = void_compute();
f.get();
}
#endif
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<int> f = compute(-1);
f.wait();
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<int> f = compute(0);
std::cout << f.get() << std::endl;
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<int&> f = compute_ref(0);
std::cout << f.get() << std::endl;
}
#if __cplusplus > 201103L
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
int i = 0;
boost::future<int&> f = boost::make_ready_future(std::ref(i));
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));
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));
std::cout << f.get() << std::endl;
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<int> f = compute(2);
std::cout << f.get() << std::endl;
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::shared_future<int> f = shared_compute(0);
std::cout << f.get() << std::endl;
}
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << "ERRORRRRR "<<"ERRORRRRR exception thrown" << std::endl;
return 2;
}
return 0;
}

View File

@@ -1,15 +1,15 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <vector>
#include <iostream>
#include <boost/thread/condition.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/thread_only.hpp>
namespace {
const int ITERS = 100;
@@ -20,7 +20,7 @@ template <typename M>
class buffer_t
{
public:
typedef typename M::scoped_lock scoped_lock;
typedef boost::unique_lock<M> scoped_lock;
buffer_t(int n)
: p(0), c(0), full(0), buf(n)
@@ -60,7 +60,7 @@ public:
for (int n = 0; n < ITERS; ++n)
{
{
boost::mutex::scoped_lock lock(io_mutex);
boost::unique_lock<boost::mutex> lock(io_mutex);
std::cout << "sending: " << n << std::endl;
}
get_buffer().send(n);
@@ -73,7 +73,7 @@ public:
{
int n = get_buffer().receive();
{
boost::mutex::scoped_lock lock(io_mutex);
boost::unique_lock<boost::mutex> lock(io_mutex);
std::cout << "received: " << n << std::endl;
}
}
@@ -81,7 +81,7 @@ public:
private:
M mutex;
boost::condition cond;
boost::condition_variable_any cond;
unsigned int p, c, full;
std::vector<int> buf;
};
@@ -89,6 +89,7 @@ private:
template <typename M>
void do_test(M* dummy=0)
{
(void)dummy;
typedef buffer_t<M> buffer_type;
buffer_type::get_buffer();
boost::thread thrd1(&buffer_type::do_receiver_thread);

View File

@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/mutex.hpp>
@@ -16,7 +16,7 @@ public:
counter() : count(0) { }
int increment() {
boost::mutex::scoped_lock scoped_lock(mutex);
boost::unique_lock<boost::mutex> scoped_lock(mutex);
return ++count;
}
@@ -30,7 +30,7 @@ counter c;
void change_count()
{
int i = c.increment();
boost::mutex::scoped_lock scoped_lock(io_mutex);
boost::unique_lock<boost::mutex> scoped_lock(io_mutex);
std::cout << "count == " << i << std::endl;
}

View File

@@ -0,0 +1,63 @@
// (C) Copyright 2012 Howard Hinnant
// (C) Copyright 2012 Vicente Botet
//
// 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)
// adapted from the example given by Howard Hinnant in
#define BOOST_THREAD_VERSION 4
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#include <boost/thread/externally_locked_stream.hpp>
void use_cerr(boost::externally_locked_stream<std::ostream> &mcerr)
{
using namespace boost;
chrono::steady_clock::time_point tf = chrono::steady_clock::now() + chrono::seconds(10);
while (chrono::steady_clock::now() < tf)
{
mcerr << "logging data to cerr\n";
this_thread::sleep_for(chrono::milliseconds(500));
}
}
void use_cout(boost::externally_locked_stream<std::ostream> &mcout)
{
using namespace boost;
chrono::steady_clock::time_point tf = chrono::steady_clock::now() + chrono::seconds(5);
while (chrono::steady_clock::now() < tf)
{
mcout << "logging data to cout\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
int main()
{
using namespace boost;
recursive_mutex terminal_mutex;
externally_locked_stream<std::ostream> mcerr(std::cerr, terminal_mutex);
externally_locked_stream<std::ostream> mcout(std::cout, terminal_mutex);
externally_locked_stream<std::istream> mcin(std::cin, terminal_mutex);
scoped_thread<> t1(boost::thread(use_cerr, boost::ref(mcerr)));
scoped_thread<> t2(boost::thread(use_cout, boost::ref(mcout)));
this_thread::sleep_for(chrono::seconds(2));
std::string nm;
{
strict_lock<recursive_mutex> lk(terminal_mutex);
std::ostream & gcout = mcout.get(lk);
//std::istream & gcin = mcin.get(lk);
gcout << "Enter name: ";
//gcin >> nm;
}
t1.join();
t2.join();
mcout << nm << '\n';
return 0;
}

View File

@@ -0,0 +1,61 @@
// (C) Copyright 2012 Howard Hinnant
// (C) Copyright 2012 Vicente Botet
//
// 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)
// adapted from the example given by Howard Hinnant in
#define BOOST_THREAD_VERSION 4
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#include <boost/thread/ostream_buffer.hpp>
void use_cerr()
{
using namespace boost;
chrono::steady_clock::time_point tf = chrono::steady_clock::now() + chrono::seconds(5);
int i = 0;
while (chrono::steady_clock::now() < tf)
{
ostream_buffer<std::ostream> mcerr(std::cerr);
mcerr.stream() << "logging data to cerr " << i++ << "\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
void use_cout()
{
using namespace boost;
chrono::steady_clock::time_point tf = chrono::steady_clock::now() + chrono::seconds(5);
int i = 0;
while (chrono::steady_clock::now() < tf)
{
ostream_buffer<std::ostream> mcout(std::cout);
mcout.stream() << "logging data to cout " << i++ << "\n";
this_thread::sleep_for(chrono::milliseconds(500));
}
}
int main()
{
using namespace boost;
scoped_thread<> t1(&use_cerr);
scoped_thread<> t2(&use_cout);
this_thread::sleep_for(chrono::seconds(2));
std::string nm = "he, he\n";
{
ostream_buffer<std::ostream> mcout(std::cout);
mcout.stream() << "Enter name: \n";
}
t1.join();
t2.join();
{
ostream_buffer<std::ostream> mcout(std::cout);
mcout.stream() << nm;
}
return 0;
}

View File

@@ -1,15 +1,23 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_PROVIDES_ONCE_CXX11
#include <boost/thread/thread.hpp>
#include <boost/thread/once.hpp>
#include <cassert>
int value=0;
boost::once_flag once = BOOST_ONCE_INIT;
#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
static boost::once_flag once;
//static boost::once_flag once2 = BOOST_ONCE_INIT;
#else
static boost::once_flag once = BOOST_ONCE_INIT;
//static boost::once_flag once2 = once;
#endif
void init()
{
@@ -21,7 +29,7 @@ void thread_proc()
boost::call_once(&init, once);
}
int main(int argc, char* argv[])
int main()
{
boost::thread_group threads;
for (int i=0; i<5; ++i)

View File

@@ -0,0 +1,102 @@
// Copyright (C) 2014 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/future.hpp>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
template<typename Iterator,typename T>
struct accumulate_block
{
//typedef T result_type;
T operator()(Iterator first,Iterator last)
{
return std::accumulate(first,last,T());
}
};
template<typename Iterator,typename T>
T parallel_accumulate(Iterator first,Iterator last,T init)
{
unsigned long const length=std::distance(first,last);
if(!length)
return init;
unsigned long const block_size=25;
unsigned long const num_blocks=(length+block_size-1)/block_size;
boost::csbl::vector<boost::future<T> > futures(num_blocks-1);
boost::basic_thread_pool pool;
Iterator block_start=first;
for(unsigned long i=0;i<(num_blocks-1);++i)
{
Iterator block_end=block_start;
std::advance(block_end,block_size);
futures[i]=boost::async(pool, accumulate_block<Iterator,T>(), block_start, block_end);
block_start=block_end;
}
T last_result=accumulate_block<Iterator,T>()(block_start,last);
T result=init;
for(unsigned long i=0;i<(num_blocks-1);++i)
{
result+=futures[i].get();
}
result += last_result;
return result;
}
int main()
{
try
{
const int s = 1001;
std::vector<int> vec;
vec.reserve(s);
for (int i=0; i<s;++i)
vec.push_back(1);
int r = parallel_accumulate(vec.begin(), vec.end(),0);
std::cout << r << std::endl;
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
return 0;
}
#else
///#warning "This compiler doesn't supports variadics"
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,110 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/future.hpp>
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#include <numeric>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
template<typename T>
struct sorter
{
boost::basic_thread_pool pool;
typedef std::list<T> return_type;
std::list<T> do_sort(std::list<T> chunk_data)
{
if(chunk_data.empty())
{
return chunk_data;
}
std::list<T> result;
result.splice(result.begin(),chunk_data, chunk_data.begin());
T const& partition_val=*result.begin();
typename std::list<T>::iterator divide_point=
std::partition(chunk_data.begin(), chunk_data.end(), [&](T const& val){return val<partition_val;});
std::list<T> new_lower_chunk;
new_lower_chunk.splice(new_lower_chunk.end(), chunk_data, chunk_data.begin(), divide_point);
boost::future<std::list<T> > new_lower = boost::async(pool, &sorter::do_sort, this, std::move(new_lower_chunk));
//boost::future<std::list<T> > new_lower = boost::async<return_type>(pool, &sorter::do_sort, this, std::move(new_lower_chunk));
std::list<T> new_higher(do_sort(chunk_data));
result.splice(result.end(),new_higher);
while(!new_lower.is_ready())
{
pool.schedule_one_or_yield();
}
result.splice(result.begin(),new_lower.get());
return result;
}
};
template<typename T>
std::list<T> parallel_quick_sort(std::list<T>& input)
{
if(input.empty())
{
return input;
}
sorter<T> s;
return s.do_sort(input);
}
int main()
{
try
{
const int s = 101;
std::list<int> lst;
for (int i=0; i<s;++i)
lst.push_back(100-i);
std::list<int> r = parallel_quick_sort(lst);
for (std::list<int>::const_iterator it=r.begin(); it != r.end(); ++it)
std::cout << *it << std::endl;
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
return 0;
}
#else
//#warning "This compiler doesn't supports variadics and move semantics"
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,237 @@
// (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)
//
// This performance test is based on the performance test provided by maxim.yegorushkin
// at https://svn.boost.org/trac/boost/ticket/7422
#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/chrono/stopwatches/simple_stopwatch.hpp>
#include <condition_variable>
#include <future>
#include <limits>
#include <cstdio>
#include <thread>
#include <mutex>
#include <vector>
////////////////////////////////////////////////////////////////////////////////////////////////
namespace
{
////////////////////////////////////////////////////////////////////////////////////////////////
// class Stopwatch
// {
// public:
// typedef long long rep;
//
// static rep now()
// {
// timespec ts;
// if (clock_gettime(CLOCK_MONOTONIC, &ts)) abort();
// return ts.tv_sec * rep(1000000000) + ts.tv_nsec;
// }
//
// Stopwatch() :
// start_(now())
// {
// }
//
// rep elapsed() const
// {
// return now() - start_;
// }
//
// private:
// rep start_;
// };
typedef boost::chrono::simple_stopwatch<> Stopwatch;
////////////////////////////////////////////////////////////////////////////////////////////////
struct BoostTypes
{
typedef boost::condition_variable condition_variable;
typedef boost::mutex mutex;
typedef boost::mutex::scoped_lock scoped_lock;
};
struct StdTypes
{
typedef std::condition_variable condition_variable;
typedef std::mutex mutex;
typedef std::unique_lock<std::mutex> scoped_lock;
};
template <class Types>
struct SharedData: Types
{
unsigned const iterations;
unsigned counter;
unsigned semaphore;
typename Types::condition_variable cnd;
typename Types::mutex mtx;
Stopwatch::rep producer_time;
SharedData(unsigned iterations, unsigned consumers) :
iterations(iterations), counter(), semaphore(consumers) // Initialize to the number of consumers. (*)
, producer_time()
{
}
};
////////////////////////////////////////////////////////////////////////////////////////////////
template <class S>
void producer_thread(S* shared_data)
{
Stopwatch sw;
unsigned const consumers = shared_data->semaphore; // (*)
for (unsigned i = shared_data->iterations; i--;)
{
{
typename S::scoped_lock lock(shared_data->mtx);
// Wait till all consumers signal.
while (consumers != shared_data->semaphore)
{
shared_data->cnd.wait(lock);
}
shared_data->semaphore = 0;
// Signal consumers.
++shared_data->counter;
}
shared_data->cnd.notify_all();
}
shared_data->producer_time = sw.elapsed().count();
}
template <class S>
void consumer_thread(S* shared_data)
{
unsigned counter = 0;
while (counter != shared_data->iterations)
{
{
typename S::scoped_lock lock(shared_data->mtx);
// Wait till the producer signals.
while (counter == shared_data->counter)
{
shared_data->cnd.wait(lock);
}
counter = shared_data->counter;
// Signal the producer.
++shared_data->semaphore;
}
shared_data->cnd.notify_all();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
template <class Types>
Stopwatch::rep benchmark_ping_pong(unsigned consumer_count)
{
typedef SharedData<Types> S;
auto best_producer_time = std::numeric_limits<Stopwatch::rep>::max BOOST_PREVENT_MACRO_SUBSTITUTION ();
std::vector<std::thread> consumers
{ consumer_count };
// Run the benchmark 10 times and report the best time.
for (int times = 10; times--;)
{
S shared_data
{ 100000, consumer_count };
// Start the consumers.
for (unsigned i = 0; i < consumer_count; ++i)
consumers[i] = std::thread
{ consumer_thread<S> , &shared_data };
// Start the producer and wait till it finishes.
std::thread
{ producer_thread<S> , &shared_data }.join();
// Wait till consumers finish.
for (unsigned i = 0; i < consumer_count; ++i)
consumers[i].join();
best_producer_time = std::min BOOST_PREVENT_MACRO_SUBSTITUTION (best_producer_time, shared_data.producer_time);
}
return best_producer_time;
}
////////////////////////////////////////////////////////////////////////////////////////////////
} // namespace
////////////////////////////////////////////////////////////////////////////////////////////////
// sudo chrt -f 99 /usr/bin/time -f "\n***\ntime: %E\ncontext switches: %c\nwaits: %w" /home/max/otsquant/build/Linux-x86_64-64.g++-release/test/test
/*
Producer-consumer ping-pong tests. It aims to benchmark condition variables with and without
thread cancellation support by comparing the time it took to complete the benchmark.
Condition variable with thread cancellation support is boost::condition_variable from
boost-1.51. Without - std::condition_variable that comes with gcc-4.7.2.
One producer, one to CONSUMER_MAX consumers. The benchmark calls
condition_variable::notify_all() without holding a mutex to maximize contention within this
function. Each benchmark for a number of consumers is run three times and the best time is
picked to get rid of outliers.
The results are reported for each benchmark for a number of consumers. The most important number
is (std - boost) / std * 100. Positive numbers are when boost::condition_variable is faster,
negative it is slower.
*/
int main()
{
std::printf("MAIN\n");
enum
{
CONSUMER_MAX = 2
};
struct
{
Stopwatch::rep boost, std;
} best_times[CONSUMER_MAX] = {};
for (unsigned i = 1; i <= CONSUMER_MAX; ++i)
{
auto& b = best_times[i - 1];
std::printf("STD: %d\n", i);
b.std = benchmark_ping_pong<StdTypes> (i);
std::printf("BOOST: %d\n", i);
b.boost = benchmark_ping_pong<BoostTypes> (i);
std::printf("consumers: %4d\n", i);
std::printf("best std producer time: %15.9fsec\n", b.std * 1e-9);
std::printf("best boost producer time: %15.9fsec\n", b.boost * 1e-9);
std::printf("(std - boost) / std: %7.2f%%\n", (b.std - b.boost) * 100. / b.std);
}
printf("\ncsv:\n\n");
printf("consumers,(std-boost)/std,std,boost\n");
for (unsigned i = 1; i <= CONSUMER_MAX; ++i)
{
auto& b = best_times[i - 1];
printf("%d,%f,%lld,%lld\n", i, (b.std - b.boost) * 100. / b.std, b.std, b.boost);
}
return 1;
}

View File

@@ -0,0 +1,72 @@
// (C) Copyright 2013 Andrey
// (C) Copyright 2013 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// This performance test is based on the performance test provided by maxim.yegorushkin
// at https://svn.boost.org/trac/boost/ticket/7422
#define BOOST_THREAD_USES_CHRONO
#include <iostream>
#include <boost/thread/lock_types.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/chrono/chrono_io.hpp>
#include <boost/thread/shared_mutex.hpp>
using namespace boost;
shared_mutex mtx;
const int cycles = 10000;
void shared()
{
int cycle(0);
while (++cycle < cycles)
{
shared_lock<shared_mutex> lock(mtx);
}
}
void unique()
{
int cycle(0);
while (++cycle < cycles)
{
unique_lock<shared_mutex> lock(mtx);
}
}
int main()
{
boost::chrono::high_resolution_clock::duration best_time(std::numeric_limits<boost::chrono::high_resolution_clock::duration::rep>::max BOOST_PREVENT_MACRO_SUBSTITUTION ());
for (int i =100; i>0; --i) {
boost::chrono::high_resolution_clock clock;
boost::chrono::high_resolution_clock::time_point s1 = clock.now();
thread t0(shared);
thread t1(shared);
thread t2(unique);
//thread t11(shared);
//thread t12(shared);
//thread t13(shared);
t0.join();
t1.join();
t2.join();
//t11.join();
// t12.join();
// t13.join();
boost::chrono::high_resolution_clock::time_point f1 = clock.now();
//std::cout << " Time spent:" << (f1 - s1) << std::endl;
best_time = std::min BOOST_PREVENT_MACRO_SUBSTITUTION (best_time, f1 - s1);
}
std::cout << "Best Time spent:" << best_time << std::endl;
std::cout << "Time spent/cycle:" << best_time/cycles/3 << std::endl;
return 1;
}

View File

@@ -0,0 +1,147 @@
// (C) Copyright 2012 Howard Hinnant
// (C) Copyright 2012 Vicente Botet
//
// 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)
// adapted from the example given by Howard Hinnant in
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#ifdef XXXX
#include <boost/thread/externally_locked_stream.hpp>
typedef boost::externally_locked_stream<std::ostream> the_ostream;
#else
typedef std::ostream the_ostream;
typedef std::istream the_istream;
#endif
#include <boost/thread/concurrent_queues/sync_queue.hpp>
void producer(the_ostream & /*mos*/, boost::sync_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
sbq.push(i);
//sbq << i;
//mos << "push(" << i << ") "<< sbq.size()<<"\n";
this_thread::sleep_for(chrono::milliseconds(200));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer(
the_ostream & /*mos*/,
boost::sync_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
sbq.pull(r);
//sbq >> r;
//mos << i << " pull(" << r << ") "<< sbq.size()<<"\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer2(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
if (queue_op_status::success == st) {
//mos << i << " pull(" << r << ")\n";
}
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer3(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
//mos << i << " wait_pull(" << r << ")\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(...)
{
//mos << "exception !!!\n";
}
}
int main()
{
using namespace boost;
#ifdef XXXX
recursive_mutex terminal_mutex;
externally_locked_stream<std::ostream> mcerr(std::cerr, terminal_mutex);
externally_locked_stream<std::ostream> mcout(std::cout, terminal_mutex);
externally_locked_stream<std::istream> mcin(std::cin, terminal_mutex);
#else
the_ostream &mcerr = std::cout;
the_ostream &mcout = std::cerr;
//the_istream &mcin = std::cin;
#endif
sync_queue<int> sbq;
{
mcout << "begin of main" << std::endl;
scoped_thread<> t11(boost::thread(producer, boost::ref(mcerr), boost::ref(sbq)));
scoped_thread<> t12(boost::thread(producer, boost::ref(mcerr), boost::ref(sbq)));
scoped_thread<> t2(boost::thread(consumer, boost::ref(mcout), boost::ref(sbq)));
this_thread::sleep_for(chrono::seconds(1));
mcout << "closed()" << std::endl;
sbq.close();
mcout << "closed()" << std::endl;
} // all threads joined here.
mcout << "end of main" << std::endl;
return 0;
}

View File

@@ -0,0 +1,150 @@
// (C) Copyright 2014 Vicente Botet
//
// 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)
// adapted from the example given by Howard Hinnant in
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#ifdef XXXX
#include <boost/thread/externally_locked_stream.hpp>
typedef boost::externally_locked_stream<std::ostream> the_ostream;
#else
typedef std::ostream the_ostream;
typedef std::istream the_istream;
#endif
#include <boost/thread/concurrent_queues/sync_queue.hpp>
#include <boost/thread/concurrent_queues/queue_adaptor.hpp>
#include <boost/thread/concurrent_queues/queue_views.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
void producer(the_ostream &/*mos*/, boost::queue_back<int> sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
sbq.push(i);
//sbq << i;
//mos << "push(" << i << ") " << sbq.size() <<"\n";
this_thread::sleep_for(chrono::milliseconds(200));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer(
the_ostream &/*mos*/,
boost::queue_front<int> sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
sbq.pull(r);
//sbq >> r;
//mos << i << " pull(" << r << ") " << sbq.size() <<"\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer2(the_ostream &/*mos*/, boost::queue_front<int> sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
if (queue_op_status::success == st) {
//mos << i << " try_pull(" << r << ")\n";
}
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer3(the_ostream &/*mos*/, boost::queue_front<int> sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
//mos << i << " wait_pull(" << r << ")\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(...)
{
//mos << "exception !!!\n";
}
}
int main()
{
using namespace boost;
#ifdef XXXX
recursive_mutex terminal_mutex;
externally_locked_stream<std::ostream> mcerr(std::cerr, terminal_mutex);
externally_locked_stream<std::ostream> mcout(std::cout, terminal_mutex);
externally_locked_stream<std::istream> mcin(std::cin, terminal_mutex);
#else
the_ostream &mcerr = std::cout;
the_ostream &mcout = std::cerr;
//the_istream &mcin = std::cin;
#endif
queue_adaptor<sync_queue<int> > sbq;
{
mcout << "begin of main" << std::endl;
scoped_thread<> t11(boost::thread(producer, boost::ref(mcerr), concurrent::queue_back<int>(sbq)));
scoped_thread<> t12(boost::thread(producer, boost::ref(mcerr), concurrent::queue_back<int>(sbq)));
scoped_thread<> t2(boost::thread(consumer, boost::ref(mcout), concurrent::queue_front<int>(sbq)));
this_thread::sleep_for(chrono::seconds(1));
mcout << "closed()" << std::endl;
sbq.close();
mcout << "closed()" << std::endl;
} // all threads joined here.
mcout << "end of main" << std::endl;
return 0;
}

View File

@@ -0,0 +1,146 @@
// (C) Copyright 2012 Howard Hinnant
// (C) Copyright 2012 Vicente Botet
//
// 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)
// adapted from the example given by Howard Hinnant in
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
//#define XXXX
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#ifdef XXXX
#include <boost/thread/externally_locked_stream.hpp>
typedef boost::externally_locked_stream<std::ostream> the_ostream;
#else
typedef std::ostream the_ostream;
typedef std::istream the_istream;
#endif
#include <boost/thread/sync_bounded_queue.hpp>
void producer(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
sbq.push_back(i);
//sbq << i;
//mos << "push_back(" << i << ") "<< sbq.size()<<"\n";
this_thread::sleep_for(chrono::milliseconds(200));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
sbq.pull_front(r);
//sbq >> r;
//mos << i << " pull_front(" << r << ") "<< sbq.size()<<"\n";
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(sync_queue_is_closed&)
{
//mos << "closed !!!\n";
}
catch(...)
{
//mos << "exception !!!\n";
}
}
void consumer2(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
{
using namespace boost;
try {
for(int i=0; ;++i)
{
int r;
queue_op_status st = sbq.try_pull_front(r);
if (queue_op_status::closed == st) break;
if (queue_op_status::success == st) {
//mos << i << " pull(" << r << ")\n";
}
this_thread::sleep_for(chrono::milliseconds(250));
}
}
catch(...)
{
//mos << "exception !!!\n";
}
}
//void consumer3(the_ostream &mos, boost::sync_bounded_queue<int> & sbq)
//{
// using namespace boost;
// bool closed=false;
// try {
// for(int i=0; ;++i)
// {
// int r;
// queue_op_status res = sbq.wait_and_pull(r);
// if (res==queue_op_status::closed) break;
// //mos << i << " wait_and_pull(" << r << ")\n";
// this_thread::sleep_for(chrono::milliseconds(250));
// }
// }
// catch(...)
// {
// //mos << "exception !!!\n";
// }
//}
int main()
{
using namespace boost;
#ifdef XXXX
recursive_mutex terminal_mutex;
externally_locked_stream<std::ostream> mcerr(std::cerr, terminal_mutex);
externally_locked_stream<std::ostream> mcout(std::cout, terminal_mutex);
externally_locked_stream<std::istream> mcin(std::cin, terminal_mutex);
#else
the_ostream &mcerr = std::cout;
the_ostream &mcout = std::cerr;
//the_istream &mcin = std::cin;
#endif
sync_bounded_queue<int> sbq(10);
{
mcout << "begin of main" << std::endl;
scoped_thread<> t11(boost::thread(producer, boost::ref(mcerr), boost::ref(sbq)));
scoped_thread<> t12(boost::thread(producer, boost::ref(mcerr), boost::ref(sbq)));
scoped_thread<> t2(boost::thread(consumer, boost::ref(mcout), boost::ref(sbq)));
this_thread::sleep_for(chrono::seconds(1));
sbq.close();
mcout << "closed()" << std::endl;
} // all threads joined here.
mcout << "end of main" << std::endl;
return 0;
}

View File

@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/recursive_mutex.hpp>
@@ -14,12 +14,12 @@ public:
counter() : count(0) { }
int add(int val) {
boost::recursive_mutex::scoped_lock scoped_lock(mutex);
boost::unique_lock<boost::recursive_mutex> scoped_lock(mutex);
count += val;
return count;
}
int increment() {
boost::recursive_mutex::scoped_lock scoped_lock(mutex);
boost::unique_lock<boost::recursive_mutex> scoped_lock(mutex);
return add(1);
}
@@ -32,7 +32,7 @@ counter c;
void change_count()
{
std::cout << "count == " << c.increment() << std::endl;
//std::cout << "count == " << c.increment() << std::endl;
}
int main(int, char*[])

83
example/scoped_thread.cpp Normal file
View File

@@ -0,0 +1,83 @@
// (C) Copyright 2009-2012 Anthony Williams
// (C) Copyright 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 3
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
void do_something(int& i)
{
++i;
}
void f(int, int)
{
}
struct func
{
int& i;
func(int& i_) :
i(i_)
{
}
void operator()()
{
for (unsigned j = 0; j < 1000000; ++j)
{
do_something(i);
}
}
};
void do_something_in_current_thread()
{
}
int main()
{
{
int some_local_state=0;
boost::strict_scoped_thread<> t( (boost::thread(func(some_local_state))));
do_something_in_current_thread();
}
{
int some_local_state=0;
boost::thread t(( func(some_local_state) ));
boost::strict_scoped_thread<> g( (boost::move(t)) );
do_something_in_current_thread();
}
{
int some_local_state=0;
boost::scoped_thread<> t( (boost::thread(func(some_local_state))));
if (t.joinable())
t.join();
else
do_something_in_current_thread();
}
#if 0
{
int some_local_state=0;
boost::thread t(( func(some_local_state) ));
boost::scoped_thread<> g( (boost::move(t)) );
if (g.joinable())
g.detach();
do_something_in_current_thread();
}
#endif
{
boost::scoped_thread<> g( &f, 1, 2 );
do_something_in_current_thread();
}
return 0;
}

107
example/serial_executor.cpp Normal file
View File

@@ -0,0 +1,107 @@
// Copyright (C) 2015 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/serial_executor.hpp>
#include <boost/thread/executors/executor.hpp>
#include <boost/thread/executors/executor_adaptor.hpp>
#include <boost/thread/executor.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
void p1()
{
//std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(30));
//std::cout << BOOST_CONTEXTOF << std::endl;
}
void p2()
{
//std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
//std::cout << BOOST_CONTEXTOF << std::endl;
}
int f1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
return 1;
}
int f2(int i)
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(2));
return i + 1;
}
void submit_some(boost::serial_executor& tp)
{
for (int i = 0; i < 3; ++i) {
std::cout << BOOST_CONTEXTOF << std::endl;
tp.submit(&p2);
}
for (int i = 0; i < 3; ++i) {
std::cout << BOOST_CONTEXTOF << std::endl;
tp.submit(&p1);
}
}
void at_th_entry(boost::basic_thread_pool& )
{
}
int test_executor_adaptor()
{
{
try
{
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
{
boost::basic_thread_pool ea1(4);
boost::serial_executor ea2(ea1);
submit_some(ea2);
boost::this_thread::sleep_for(boost::chrono::seconds(10));
}
#endif
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
}
return 0;
}
int main()
{
return test_executor_adaptor();
}

View File

@@ -0,0 +1,113 @@
// Copyright (C) 2015 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/serial_executor_cont.hpp>
#include <boost/thread/executors/executor.hpp>
#include <boost/thread/executors/executor_adaptor.hpp>
#include <boost/thread/executor.hpp>
#include <boost/thread/future.hpp>
#include <boost/assert.hpp>
#include <string>
#include <iostream>
void p1()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(30));
std::cout << BOOST_CONTEXTOF << std::endl;
}
void p2()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
std::cout << BOOST_CONTEXTOF << std::endl;
}
int f1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(1));
return 1;
}
int f2(int i)
{
// std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::seconds(2));
return i + 1;
}
void submit_some(boost::serial_executor_cont& tp)
{
std::cout << BOOST_CONTEXTOF << std::endl;
for (int i = 0; i < 3; ++i) {
std::cout << BOOST_CONTEXTOF << std::endl;
tp.submit(&p2);
}
for (int i = 0; i < 3; ++i) {
std::cout << BOOST_CONTEXTOF << std::endl;
tp.submit(&p1);
}
std::cout << BOOST_CONTEXTOF << std::endl;
}
void at_th_entry(boost::basic_thread_pool& )
{
}
int test_executor_adaptor()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
{
try
{
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
// std::cout << BOOST_CONTEXTOF << std::endl;
{
boost::basic_thread_pool ea1(4);
boost::serial_executor_cont ea2(ea1);
submit_some(ea2);
boost::this_thread::sleep_for(boost::chrono::seconds(10));
}
#endif
// std::cout << BOOST_CONTEXTOF << std::endl;
}
catch (std::exception& ex)
{
std::cout << "ERROR= " << ex.what() << "" << std::endl;
return 1;
}
catch (...)
{
std::cout << " ERROR= exception thrown" << std::endl;
return 2;
}
}
// std::cout << BOOST_CONTEXTOF << std::endl;
return 0;
}
int main()
{
return test_executor_adaptor();
}

144
example/shared_monitor.cpp Normal file
View File

@@ -0,0 +1,144 @@
// Copyright (C) 2012 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/lock_algorithms.hpp>
#include <boost/thread/thread_only.hpp>
#if defined BOOST_THREAD_DONT_USE_CHRONO
#include <boost/chrono/chrono_io.hpp>
#endif
#include <cassert>
#include <vector>
#define EXCLUSIVE 1
#define SHARED 2
#define MODE SHARED
class A
{
#if MODE == EXCLUSIVE
typedef boost::mutex mutex_type;
#elif MODE == SHARED
typedef boost::shared_mutex mutex_type;
#else
#error MODE not set
#endif
typedef std::vector<double> C;
mutable mutex_type mut_;
C data_;
public:
A() : data_(10000000) {}
A(const A& a);
A& operator=(const A& a);
void compute(const A& x, const A& y);
};
A::A(const A& a)
{
#if MODE == EXCLUSIVE
boost::unique_lock<mutex_type> lk(a.mut_);
#elif MODE == SHARED
boost::shared_lock<mutex_type> lk(a.mut_);
#else
#error MODE not set
#endif
data_ = a.data_;
}
A&
A::operator=(const A& a)
{
if (this != &a)
{
boost::unique_lock<mutex_type> lk1(mut_, boost::defer_lock);
#if MODE == EXCLUSIVE
boost::unique_lock<mutex_type> lk2(a.mut_, boost::defer_lock);
#elif MODE == SHARED
boost::shared_lock<mutex_type> lk2(a.mut_, boost::defer_lock);
#else
#error MODE not set
#endif
boost::lock(lk1, lk2);
data_ = a.data_;
}
return *this;
}
void
A::compute(const A& x, const A& y)
{
boost::unique_lock<mutex_type> lk1(mut_, boost::defer_lock);
#if MODE == EXCLUSIVE
boost::unique_lock<mutex_type> lk2(x.mut_, boost::defer_lock);
boost::unique_lock<mutex_type> lk3(y.mut_, boost::defer_lock);
#elif MODE == SHARED
boost::shared_lock<mutex_type> lk2(x.mut_, boost::defer_lock);
boost::shared_lock<mutex_type> lk3(y.mut_, boost::defer_lock);
#else
#error MODE not set
#endif
boost::lock(lk1, lk2, lk3);
assert(data_.size() == x.data_.size());
assert(data_.size() == y.data_.size());
for (unsigned i = 0; i < data_.size(); ++i)
data_[i] = (x.data_[i] + y.data_[i]) / 2;
}
A a1;
A a2;
void test_s()
{
A la3 = a1;
for (int i = 0; i < 150; ++i)
{
la3.compute(a1, a2);
}
}
void test_w()
{
A la3 = a1;
for (int i = 0; i < 10; ++i)
{
la3.compute(a1, a2);
a1 = la3;
a2 = la3;
#if defined BOOST_THREAD_DONT_USE_CHRONO
boost::this_thread::sleep_for(boost::chrono::seconds(1));
#endif
}
}
int main()
{
#if defined BOOST_THREAD_DONT_USE_CHRONO
typedef boost::chrono::high_resolution_clock Clock;
typedef boost::chrono::duration<double> sec;
Clock::time_point t0 = Clock::now();
#endif
std::vector<boost::thread*> v;
boost::thread thw(test_w);
v.push_back(&thw);
boost::thread thr0(test_w);
v.push_back(&thr0);
boost::thread thr1(test_w);
v.push_back(&thr1);
boost::thread thr2(test_w);
v.push_back(&thr2);
boost::thread thr3(test_w);
v.push_back(&thr3);
for (std::size_t i = 0; i < v.size(); ++i)
v[i]->join();
#if defined BOOST_THREAD_DONT_USE_CHRONO
Clock::time_point t1 = Clock::now();
std::cout << sec(t1-t0) << '\n';
#endif
return 0;
}

746
example/shared_mutex.cpp Normal file
View File

@@ -0,0 +1,746 @@
// Copyright (C) 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)
#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
#include <iostream>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/lock_algorithms.hpp>
#include <boost/thread/thread_only.hpp>
#include <vector>
#if defined BOOST_THREAD_USES_CHRONO
#include <boost/chrono/chrono_io.hpp>
enum {reading, writing};
int state = reading;
#if 1
boost::mutex&
cout_mut()
{
static boost::mutex m;
return m;
}
void
print(const char* tag, unsigned count, char ch)
{
boost::lock_guard<boost::mutex> _(cout_mut());
std::cout << tag << count << ch;
}
#elif 0
boost::recursive_mutex&
cout_mut()
{
static boost::recursive_mutex m;
return m;
}
void print() {}
template <class A0, class ...Args>
void
print(const A0& a0, const Args& ...args)
{
boost::lock_guard<boost::recursive_mutex> _(cout_mut());
std::cout << a0;
print(args...);
}
#else
template <class A0, class A1, class A2>
void
print(const A0&, const A1& a1, const A2&)
{
assert(a1 > 10000);
}
#endif
namespace S
{
boost::shared_mutex mut;
void reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock_shared();
assert(state == reading);
++count;
mut.unlock_shared();
}
print("reader = ", count, '\n');
}
void writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock();
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
print("writer = ", count, '\n');
}
void try_reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared())
{
assert(state == reading);
++count;
mut.unlock_shared();
}
}
print("try_reader = ", count, '\n');
}
void try_writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock())
{
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
}
print("try_writer = ", count, '\n');
}
void try_for_reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
++count;
mut.unlock_shared();
}
}
print("try_for_reader = ", count, '\n');
}
void try_for_writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_for(boost::chrono::microseconds(5)))
{
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
}
print("try_for_writer = ", count, '\n');
}
void
test_shared_mutex()
{
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(reader);
boost::thread t2(writer);
boost::thread t3(reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(try_reader);
boost::thread t2(try_writer);
boost::thread t3(try_reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(try_for_reader);
boost::thread t2(try_for_writer);
boost::thread t3(try_for_reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
}
}
namespace U
{
boost::upgrade_mutex mut;
void reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock_shared();
assert(state == reading);
++count;
mut.unlock_shared();
}
print("reader = ", count, '\n');
}
void writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock();
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
print("writer = ", count, '\n');
}
void try_reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared())
{
assert(state == reading);
++count;
mut.unlock_shared();
}
}
print("try_reader = ", count, '\n');
}
void try_writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock())
{
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
}
print("try_writer = ", count, '\n');
}
void try_for_reader()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
++count;
mut.unlock_shared();
}
}
print("try_for_reader = ", count, '\n');
}
void try_for_writer()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_for(boost::chrono::microseconds(5)))
{
state = writing;
assert(state == writing);
state = reading;
++count;
mut.unlock();
}
}
print("try_for_writer = ", count, '\n');
}
void upgradable()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock_upgrade();
assert(state == reading);
++count;
mut.unlock_upgrade();
}
print("upgradable = ", count, '\n');
}
void try_upgradable()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_upgrade())
{
assert(state == reading);
++count;
mut.unlock_upgrade();
}
}
print("try_upgradable = ", count, '\n');
}
void try_for_upgradable()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_upgrade_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
++count;
mut.unlock_upgrade();
}
}
print("try_for_upgradable = ", count, '\n');
}
void clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock_shared();
assert(state == reading);
if (mut.try_unlock_shared_and_lock())
{
state = writing;
}
else if (mut.try_unlock_shared_and_lock_upgrade())
{
assert(state == reading);
mut.unlock_upgrade_and_lock();
state = writing;
}
else
{
mut.unlock_shared();
continue;
}
assert(state == writing);
state = reading;
mut.unlock_and_lock_upgrade();
assert(state == reading);
mut.unlock_upgrade_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
print("clockwise = ", count, '\n');
}
void counter_clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
mut.lock_upgrade();
assert(state == reading);
mut.unlock_upgrade_and_lock();
assert(state == reading);
state = writing;
assert(state == writing);
state = reading;
mut.unlock_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
print("counter_clockwise = ", count, '\n');
}
void try_clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared())
{
assert(state == reading);
if (mut.try_unlock_shared_and_lock())
{
state = writing;
}
else if (mut.try_unlock_shared_and_lock_upgrade())
{
assert(state == reading);
mut.unlock_upgrade_and_lock();
state = writing;
}
else
{
mut.unlock_shared();
continue;
}
assert(state == writing);
state = reading;
mut.unlock_and_lock_upgrade();
assert(state == reading);
mut.unlock_upgrade_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
}
print("try_clockwise = ", count, '\n');
}
void try_for_clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_shared_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
if (mut.try_unlock_shared_and_lock_for(boost::chrono::microseconds(5)))
{
state = writing;
}
else if (mut.try_unlock_shared_and_lock_upgrade_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
mut.unlock_upgrade_and_lock();
state = writing;
}
else
{
mut.unlock_shared();
continue;
}
assert(state == writing);
state = reading;
mut.unlock_and_lock_upgrade();
assert(state == reading);
mut.unlock_upgrade_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
}
print("try_for_clockwise = ", count, '\n');
}
void try_counter_clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_upgrade())
{
assert(state == reading);
if (mut.try_unlock_upgrade_and_lock())
{
assert(state == reading);
state = writing;
assert(state == writing);
state = reading;
mut.unlock_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
else
{
mut.unlock_upgrade();
}
}
}
print("try_counter_clockwise = ", count, '\n');
}
void try_for_counter_clockwise()
{
typedef boost::chrono::steady_clock Clock;
unsigned count = 0;
Clock::time_point until = Clock::now() + boost::chrono::seconds(3);
while (Clock::now() < until)
{
if (mut.try_lock_upgrade_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
if (mut.try_unlock_upgrade_and_lock_for(boost::chrono::microseconds(5)))
{
assert(state == reading);
state = writing;
assert(state == writing);
state = reading;
mut.unlock_and_lock_shared();
assert(state == reading);
mut.unlock_shared();
++count;
}
else
{
mut.unlock_upgrade();
}
}
}
print("try_for_counter_clockwise = ", count, '\n');
}
void
test_upgrade_mutex()
{
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(reader);
boost::thread t2(writer);
boost::thread t3(reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(try_reader);
boost::thread t2(try_writer);
boost::thread t3(try_reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(try_for_reader);
boost::thread t2(try_for_writer);
boost::thread t3(try_for_reader);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(reader);
boost::thread t2(writer);
boost::thread t3(upgradable);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(reader);
boost::thread t2(writer);
boost::thread t3(try_upgradable);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
boost::thread t1(reader);
boost::thread t2(writer);
boost::thread t3(try_for_upgradable);
t1.join();
t2.join();
t3.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
state = reading;
boost::thread t1(clockwise);
boost::thread t2(counter_clockwise);
boost::thread t3(clockwise);
boost::thread t4(counter_clockwise);
t1.join();
t2.join();
t3.join();
t4.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
{
state = reading;
boost::thread t1(try_clockwise);
boost::thread t2(try_counter_clockwise);
t1.join();
t2.join();
}
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
// {
// state = reading;
// boost::thread t1(try_for_clockwise);
// boost::thread t2(try_for_counter_clockwise);
// t1.join();
// t2.join();
// }
// std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
}
}
namespace Assignment
{
class A
{
typedef boost::upgrade_mutex mutex_type;
typedef boost::shared_lock<mutex_type> SharedLock;
typedef boost::upgrade_lock<mutex_type> UpgradeLock;
typedef boost::unique_lock<mutex_type> Lock;
mutable mutex_type mut_;
std::vector<double> data_;
public:
A(const A& a)
{
SharedLock _(a.mut_);
data_ = a.data_;
}
A& operator=(const A& a)
{
if (this != &a)
{
Lock this_lock(mut_, boost::defer_lock);
SharedLock that_lock(a.mut_, boost::defer_lock);
boost::lock(this_lock, that_lock);
data_ = a.data_;
}
return *this;
}
void swap(A& a)
{
Lock this_lock(mut_, boost::defer_lock);
Lock that_lock(a.mut_, boost::defer_lock);
boost::lock(this_lock, that_lock);
data_.swap(a.data_);
}
void average(A& a)
{
assert(data_.size() == a.data_.size());
assert(this != &a);
Lock this_lock(mut_, boost::defer_lock);
UpgradeLock share_that_lock(a.mut_, boost::defer_lock);
boost::lock(this_lock, share_that_lock);
for (unsigned i = 0; i < data_.size(); ++i)
data_[i] = (data_[i] + a.data_[i]) / 2;
SharedLock share_this_lock(boost::move(this_lock));
Lock that_lock(boost::move(share_that_lock));
a.data_ = data_;
}
};
} // Assignment
void temp()
{
using namespace boost;
static upgrade_mutex mut;
unique_lock<upgrade_mutex> ul(mut);
shared_lock<upgrade_mutex> sl;
sl = BOOST_THREAD_MAKE_RV_REF(shared_lock<upgrade_mutex>(boost::move(ul)));
}
int main()
{
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
typedef boost::chrono::high_resolution_clock Clock;
typedef boost::chrono::duration<double> sec;
Clock::time_point t0 = Clock::now();
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
S::test_shared_mutex();
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
U::test_upgrade_mutex();
std::cout << __FILE__ << "[" <<__LINE__ << "]" << std::endl;
Clock::time_point t1 = Clock::now();
std::cout << sec(t1 - t0) << '\n';
return 0;
}
#else
#error "This platform doesn't support Boost.Chrono"
#endif

View File

@@ -1,12 +1,14 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/xtime.hpp>
#include <iostream>
#include <time.h>
@@ -23,18 +25,18 @@ public:
void get(int id)
{
boost::mutex::scoped_lock lock(m_mutex);
boost::unique_lock<boost::mutex> lock(m_mutex);
while (m_chickens == 0)
{
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock() << ") Phil" << id <<
": wot, no chickens? I'll WAIT ..." << std::endl;
}
m_condition.wait(lock);
}
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock() << ") Phil" << id <<
": those chickens look good ... one please ..." << std::endl;
}
@@ -42,20 +44,20 @@ public:
}
void put(int value)
{
boost::mutex::scoped_lock lock(m_mutex);
boost::unique_lock<boost::mutex> lock(m_mutex);
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock()
<< ") Chef: ouch ... make room ... this dish is "
<< "very hot ..." << std::endl;
}
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 3;
boost::thread::sleep(xt);
m_chickens += value;
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock() <<
") Chef: more chickens ... " << m_chickens <<
" now available ... NOTIFYING ..." << std::endl;
@@ -75,21 +77,21 @@ void chef()
{
const int chickens = 4;
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lock(iomx);
std::cout << "(" << clock() << ") Chef: starting ..." << std::endl;
}
for (;;)
{
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lock(iomx);
std::cout << "(" << clock() << ") Chef: cooking ..." << std::endl;
}
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 2;
boost::thread::sleep(xt);
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lock(iomx);
std::cout << "(" << clock() << ") Chef: " << chickens
<< " chickens, ready-to-go ..." << std::endl;
}
@@ -102,7 +104,7 @@ struct phil
phil(int id) : m_id(id) { }
void run() {
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lock(iomx);
std::cout << "(" << clock() << ") Phil" << m_id
<< ": starting ..." << std::endl;
}
@@ -111,18 +113,18 @@ struct phil
if (m_id > 0)
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 3;
boost::thread::sleep(xt);
}
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock() << ") Phil" << m_id
<< ": gotta eat ..." << std::endl;
}
g_canteen.get(m_id);
{
boost::mutex::scoped_lock lock(iomx);
boost::unique_lock<boost::mutex> lk(iomx);
std::cout << "(" << clock() << ") Phil" << m_id
<< ": mmm ... that's good ..." << std::endl;
}
@@ -164,7 +166,7 @@ private:
void* _param;
};
int main(int argc, char* argv[])
int main()
{
boost::thread thrd_chef(&chef);
phil p[] = { phil(0), phil(1), phil(2), phil(3), phil(4) };

View File

@@ -0,0 +1,112 @@
// (C) Copyright 2009-2012 Anthony Williams
// (C) Copyright 2012 Vicente Botet
//
// 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)
#if __cplusplus < 201103L
int main()
{
return 0;
}
#else
#define BOOST_THREAD_VERSION 3
#include <iostream>
#include <boost/thread/scoped_thread.hpp>
#include <thread>
#include <cassert>
void do_something(int& i)
{
++i;
}
void f(int, int)
{
}
struct func
{
int& i;
func(int& i_) :
i(i_)
{
}
void operator()()
{
for (unsigned j = 0; j < 1000000; ++j)
{
do_something(i);
}
}
};
void do_something_in_current_thread()
{
}
using strict_scoped_thread = boost::strict_scoped_thread<boost::join_if_joinable, std::thread>;
using scoped_thread = boost::scoped_thread<boost::join_if_joinable, std::thread>;
int main()
{
{
int some_local_state=0;
strict_scoped_thread t( (std::thread(func(some_local_state))));
do_something_in_current_thread();
}
{
int some_local_state=0;
std::thread t(( func(some_local_state) ));
strict_scoped_thread g( (boost::move(t)) );
do_something_in_current_thread();
}
{
int some_local_state=0;
std::thread t(( func(some_local_state) ));
strict_scoped_thread g( (std::move(t)) );
do_something_in_current_thread();
}
{
int some_local_state=1;
scoped_thread t( (std::thread(func(some_local_state))));
if (t.joinable()) {
t.join();
assert( ! t.joinable() );
}
else
do_something_in_current_thread();
}
#if 0
try
{
int some_local_state=1;
std::thread t(( func(some_local_state) ));
scoped_thread g( (boost::move(t)) );
if (g.joinable()) {
// CLANG crash here
g.detach();
assert( ! g.joinable() );
}
do_something_in_current_thread();
}
catch (...) {
assert( false);
}
#endif
{
scoped_thread g( &f, 1, 2 );
do_something_in_current_thread();
}
return 0;
}
#endif

View File

@@ -0,0 +1,66 @@
// (C) Copyright 2009-2012 Anthony Williams
// (C) Copyright 2012 Vicente Botet
//
// 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)
#if __cplusplus < 201103L
int main()
{
return 0;
}
#else
#include <iostream>
#include <string>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/thread_guard.hpp>
#include <thread>
void do_something(int& i)
{
++i;
}
struct func
{
int& i;
func(int& i_):i(i_){}
void operator()()
{
for(unsigned j=0;j<1000000;++j)
{
do_something(i);
}
}
private:
func& operator=(func const&);
};
void do_something_in_current_thread()
{}
using thread_guard = boost::thread_guard<boost::join_if_joinable, std::thread>;
void f()
{
int some_local_state;
func my_func(some_local_state);
std::thread t(my_func);
thread_guard g(t);
do_something_in_current_thread();
}
int main()
{
f();
return 0;
}
#endif

40
example/strict_lock.cpp Normal file
View File

@@ -0,0 +1,40 @@
// Copyright (C) 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 4
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_traits.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/strict_lock.hpp>
#include <boost/thread/lock_types.hpp>
#include <iostream>
BOOST_STATIC_ASSERT(boost::is_strict_lock<boost::strict_lock<boost::mutex> >::value);
BOOST_CONCEPT_ASSERT(( boost::BasicLockable<boost::mutex> ));
BOOST_CONCEPT_ASSERT(( boost::StrictLock<boost::strict_lock<boost::mutex> > ));
int main()
{
{
boost::mutex mtx;
boost::strict_lock<boost::mutex> lk(mtx);
std::cout << __FILE__ << std::endl;
}
{
boost::timed_mutex mtx;
boost::unique_lock<boost::timed_mutex> lk(mtx);
boost::nested_strict_lock<boost::unique_lock<boost::timed_mutex> > nlk(lk);
std::cout << __FILE__ << std::endl;
}
{
boost::mutex mtx;
boost::unique_lock<boost::mutex> lk(mtx, boost::defer_lock);
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > nlk(lk);
std::cout << __FILE__ << std::endl;
}
return 0;
}

View File

@@ -0,0 +1,282 @@
// (C) Copyright 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 4
#include <iostream>
#include <string>
#include <boost/thread/synchronized_value.hpp>
//class SafePerson {
//public:
// std::string GetName() const {
// const_unique_access<std::string> name(nameGuard);
// return *name;
// }
// void SetName(const std::string& newName) {
// unique_access<std::string> name(nameGuard);
// *name = newName;
// }
//private:
// unique_access_guard<std::string> nameGuard;
//};
class SafePerson {
public:
std::string GetName() const {
return *name;
}
void SetName(const std::string& newName) {
*name = newName;
}
private:
boost::synchronized_value<std::string> name;
};
class Person {
public:
std::string GetName() const {
return name;
}
void SetName(const std::string& newName) {
name = newName;
}
private:
std::string name;
};
typedef boost::synchronized_value<Person> Person_ts;
//class SafeMemberPerson {
//public:
// SafeMemberPerson(unsigned int age) :
// memberGuard(age)
// { }
// std::string GetName() const {
// const_unique_access<Member> member(memberGuard);
// return member->name;
// }
// void SetName(const std::string& newName) {
// unique_access<Member> member(memberGuard);
// member->name = newName;
// }
//private:
// struct Member
// {
// Member(unsigned int age) :
// age(age)
// { }
// std::string name;
// unsigned int age;
// };
// unique_access_guard<Member> memberGuard;
//};
class SafeMemberPerson {
public:
SafeMemberPerson(unsigned int age) :
member(Member(age))
{ }
std::string GetName() const {
return member->name;
}
void SetName(const std::string& newName) {
member->name = newName;
}
private:
struct Member {
Member(unsigned int age) :
age(age)
{ }
std::string name;
unsigned int age;
};
boost::synchronized_value<Member> member;
};
class Person2 {
public:
Person2(unsigned int age) : age_(age)
{}
std::string GetName() const {
return name_;
}
void SetName(const std::string& newName) {
name_ = newName;
}
unsigned int GetAge() const {
return age_;
}
private:
std::string name_;
unsigned int age_;
};
typedef boost::synchronized_value<Person2> Person2_ts;
//===================
//class HelperPerson {
//public:
// HelperPerson(unsigned int age) :
// memberGuard(age)
// { }
// std::string GetName() const {
// const_unique_access<Member> member(memberGuard);
// Invariant(member);
// return member->name;
// }
// void SetName(const std::string& newName) {
// unique_access<Member> member(memberGuard);
// Invariant(member);
// member->name = newName;
// }
//private:
// void Invariant(const_unique_access<Member>& member) const {
// if (member->age < 0) throw std::runtime_error("Age cannot be negative");
// }
// struct Member {
// Member(unsigned int age) :
// age(age)
// { }
// std::string name;
// unsigned int age;
// };
// unique_access_guard<Member> memberGuard;
//};
class HelperPerson {
public:
HelperPerson(unsigned int age) :
member(age)
{ }
std::string GetName() const {
#if ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
auto memberSync = member.synchronize();
#else
boost::const_strict_lock_ptr<Member> memberSync = member.synchronize();
#endif
Invariant(memberSync);
return memberSync->name;
}
void SetName(const std::string& newName) {
#if ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
auto memberSync = member.synchronize();
#else
boost::strict_lock_ptr<Member> memberSync = member.synchronize();
#endif
Invariant(memberSync);
memberSync->name = newName;
}
private:
struct Member {
Member(unsigned int age) :
age(age)
{ }
std::string name;
unsigned int age;
};
void Invariant(boost::const_strict_lock_ptr<Member> & mbr) const
{
if (mbr->age < 1) throw std::runtime_error("Age cannot be negative");
}
boost::synchronized_value<Member> member;
};
class Person3 {
public:
Person3(unsigned int age) :
age_(age)
{ }
std::string GetName() const {
Invariant();
return name_;
}
void SetName(const std::string& newName) {
Invariant();
name_ = newName;
}
private:
std::string name_;
unsigned int age_;
void Invariant() const {
if (age_ < 1) throw std::runtime_error("Age cannot be negative");
}
};
typedef boost::synchronized_value<Person3> Person3_ts;
int main()
{
{
SafePerson p;
p.SetName("Vicente");
}
{
Person_ts p;
p->SetName("Vicente");
}
{
SafeMemberPerson p(1);
p.SetName("Vicente");
}
{
Person2_ts p(1);
p->SetName("Vicente");
}
{
HelperPerson p(1);
p.SetName("Vicente");
}
{
Person3_ts p(1);
p->SetName("Vicente");
}
{
Person3_ts p1(1);
Person3_ts p2(2);
Person3_ts p3(3);
#if ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
auto lk1 = p1.unique_synchronize(boost::defer_lock);
auto lk2 = p2.unique_synchronize(boost::defer_lock);
auto lk3 = p3.unique_synchronize(boost::defer_lock);
#else
boost::unique_lock_ptr<Person3> lk1 = p1.unique_synchronize(boost::defer_lock);
boost::unique_lock_ptr<Person3> lk2 = p2.unique_synchronize(boost::defer_lock);
boost::unique_lock_ptr<Person3> lk3 = p3.unique_synchronize(boost::defer_lock);
#endif
boost::lock(lk1,lk2,lk3);
lk1->SetName("Carmen");
lk2->SetName("Javier");
lk3->SetName("Matias");
}
#if ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS \
&& ! defined(BOOST_THREAD_NO_SYNCHRONIZE)
{
Person3_ts p1(1);
Person3_ts p2(2);
Person3_ts p3(3);
auto t = boost::synchronize(p1,p2,p3);
std::get<0>(t)->SetName("Carmen");
std::get<1>(t)->SetName("Javier");
std::get<2>(t)->SetName("Matias");
}
{
const Person3_ts p1(1);
Person3_ts p2(2);
const Person3_ts p3(3);
auto t = boost::synchronize(p1,p2,p3);
//std::get<0>(t)->SetName("Carmen");
std::get<1>(t)->SetName("Javier");
//std::get<2>(t)->SetName("Matias");
}
#endif
return 0;
}

View File

@@ -0,0 +1,147 @@
// (C) Copyright 2010 Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
// (C) Copyright 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 4
#include <iostream>
#include <string>
#include <boost/thread/synchronized_value.hpp>
void addTrailingSlashIfMissing(boost::synchronized_value<std::string> & path)
{
boost::strict_lock_ptr<std::string> u=path.synchronize();
if(u->empty() || (*u->rbegin()!='/'))
{
*u+='/';
}
}
void f(const boost::synchronized_value<int> &v) {
std::cout<<"v="<<*v<<std::endl;
}
void g(const boost::const_strict_lock_ptr<int> &v) {
std::cout<<"v="<<*v<<std::endl;
}
bool checkIfMissingTrailingSlash(boost::synchronized_value<std::string> & path)
{
boost::strict_lock_ptr<std::string> u=path.synchronize();
return (u->empty() || (*u->rbegin()!='/'));
}
int main()
{
{
boost::synchronized_value<int> v1;
*v1=42;
std::cout<<"v1="<<*v1<<std::endl;
f(v1);
int i=*v1;
std::cout<<"i="<<i<<std::endl;
{
boost::strict_lock_ptr<int> u=v1.synchronize();
*u+=43;
std::cout<<"v1="<<*u<<std::endl;
g(u);
}
boost::synchronized_value<int> v2(2);
std::cout<<"v2="<<*v2<<std::endl;
v2 = 3;
std::cout<<"v2="<<*v2<<std::endl;
boost::synchronized_value<int> v3(v2);
std::cout<<"v3="<<*v3<<std::endl;
v3 = v1;
std::cout<<"v3="<<*v3<<std::endl;
std::cout<<"v2="<<*v3<<std::endl;
std::cout<<"v3="<<*v3<<std::endl;
swap(v3,v2);
v1.swap(v2);
std::cout<<"v3="<<*v3<<std::endl;
}
{
boost::synchronized_value<std::string> s;
addTrailingSlashIfMissing(s);
std::cout<<"s="<<std::string(*s)<<std::endl;
}
{
boost::synchronized_value<std::string> s;
s->append("foo/");
s.synchronize()->append("foo");
addTrailingSlashIfMissing(s);
std::cout<<"s="<<std::string(*s)<<std::endl;
}
{
boost::synchronized_value<std::string> s;
s = std::string("foo/");
std::cout<<"ss="<< s << std::endl;
}
{
boost::synchronized_value<std::string> s;
s = "foo/";
std::cout<<"ss="<< s << std::endl;
}
{
boost::synchronized_value<std::string> s1("a");
boost::synchronized_value<std::string> s2;
s2=s1;
std::cout<<"s1="<< s1 << std::endl;
std::cout<<"s2="<< s2 << std::endl;
}
{
boost::synchronized_value<std::string> s1("a");
boost::synchronized_value<std::string> s2("b");
std::cout<<"s1="<< s1 << std::endl;
std::cout<<"s2="<< s2 << std::endl;
swap(s1,s2);
std::cout<<"s1="<< s1 << std::endl;
std::cout<<"s2="<< s2 << std::endl;
}
#if ! defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
{
boost::synchronized_value<std::string> sts("a");
std::string s(sts);
std::cout<<"ssts="<< s << std::endl;
}
#endif
{
boost::synchronized_value<int> s1(1);
boost::synchronized_value<int> s2(1);
BOOST_ASSERT(s1==s2);
BOOST_ASSERT(s1<=s2);
BOOST_ASSERT(s1>=s2);
BOOST_ASSERT(s1==1);
BOOST_ASSERT(s1<=1);
BOOST_ASSERT(s1>=1);
}
{
boost::synchronized_value<int> s1(1);
boost::synchronized_value<int> s2(2);
BOOST_ASSERT(s1!=s2);
BOOST_ASSERT(s1!=2);
BOOST_ASSERT(2!=s1);
}
{
boost::synchronized_value<int> s1(1);
boost::synchronized_value<int> s2(2);
BOOST_ASSERT(s1<s2);
BOOST_ASSERT(s1<=s2);
BOOST_ASSERT(s2>s1);
BOOST_ASSERT(s2>=s1);
BOOST_ASSERT(s1<2);
BOOST_ASSERT(s1<=2);
BOOST_ASSERT(s2>1);
BOOST_ASSERT(s2>=1);
}
return 0;
}

View File

@@ -1,12 +1,15 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// 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)
#undef BOOST_THREAD_VERSION
#define BOOST_THREAD_VERSION 2
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/xtime.hpp>
#include <iostream>
@@ -29,26 +32,25 @@ int state;
boost::mutex mutex;
boost::condition cond;
char* player_name(int state)
const char* player_name(int state)
{
if (state == PLAYER_A)
return "PLAYER-A";
if (state == PLAYER_B)
return "PLAYER-B";
throw "bad player";
return 0;
//return 0;
}
void player(void* param)
void player(int active)
{
boost::mutex::scoped_lock lock(mutex);
boost::unique_lock<boost::mutex> lock(mutex);
int active = (int)param;
int other = active == PLAYER_A ? PLAYER_B : PLAYER_A;
while (state < GAME_OVER)
{
std::cout << player_name(active) << ": Play." << std::endl;
//std::cout << player_name(active) << ": Play." << std::endl;
state = other;
cond.notify_all();
do
@@ -96,27 +98,27 @@ private:
void* _param;
};
int main(int argc, char* argv[])
int main()
{
state = START;
boost::thread thrda(thread_adapter(&player, (void*)PLAYER_A));
boost::thread thrdb(thread_adapter(&player, (void*)PLAYER_B));
boost::thread thrda(&player, PLAYER_A);
boost::thread thrdb(&player, PLAYER_B);
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1;
boost::thread::sleep(xt);
{
boost::mutex::scoped_lock lock(mutex);
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "---Noise ON..." << std::endl;
}
for (int i = 0; i < 1000000000; ++i)
for (int i = 0; i < 10; ++i)
cond.notify_all();
{
boost::mutex::scoped_lock lock(mutex);
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "---Noise OFF..." << std::endl;
state = GAME_OVER;
cond.notify_all();

86
example/this_executor.cpp Normal file
View File

@@ -0,0 +1,86 @@
// Copyright (C) 2014 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_PROVIDES_EXECUTORS
#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/caller_context.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/thread/executors/generic_executor_ref.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <string>
#include <iostream>
#include <boost/thread/caller_context.hpp>
struct current_executor_state_type {
boost::shared_ptr<boost::generic_executor_ref> current_executor_ptr;
template <class Executor>
void set_current_executor(Executor& ex)
{
current_executor_ptr = boost::make_shared<boost::generic_executor_ref>(ex);
}
boost::generic_executor_ref current_executor()
{
if (current_executor_ptr)
return *current_executor_ptr;
else
throw "";
}
};
thread_local current_executor_state_type current_executor_state;
boost::generic_executor_ref current_executor()
{
return current_executor_state.current_executor();
}
void p2()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
std::cout << BOOST_CONTEXTOF << std::endl;
}
void p1()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
current_executor().submit(&p2);
boost::this_thread::sleep_for(boost::chrono::milliseconds(400));
std::cout << BOOST_CONTEXTOF << std::endl;
}
int main()
{
std::cout << BOOST_CONTEXTOF << std::endl;
boost::basic_thread_pool tp(4,
// at_thread_entry
[](boost::basic_thread_pool& pool)
{
current_executor_state.set_current_executor(pool);
}
);
tp.submit(&p1);
boost::this_thread::sleep_for(boost::chrono::seconds(5));
std::cout << BOOST_CONTEXTOF << std::endl;
return 1;
}

View File

@@ -1,10 +1,12 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/thread.hpp>
#define BOOST_THREAD_VERSION 2
#include <boost/thread/thread_only.hpp>
#include <boost/thread/xtime.hpp>
#include <iostream>
@@ -14,7 +16,7 @@ struct thread_alarm
void operator()()
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += m_secs;
boost::thread::sleep(xt);
@@ -25,7 +27,7 @@ struct thread_alarm
int m_secs;
};
int main(int argc, char* argv[])
int main()
{
int secs = 5;
std::cout << "setting alarm for 5 seconds..." << std::endl;

View File

@@ -1,25 +1,73 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/thread.hpp>
#include <iostream>
#include <boost/detail/lightweight_test.hpp>
int count = 0;
boost::mutex mutex;
void increment_count()
{
boost::mutex::scoped_lock lock(mutex);
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "count = " << ++count << std::endl;
}
int main(int argc, char* argv[])
boost::thread_group threads2;
boost::thread* th2 = 0;
void increment_count_2()
{
boost::unique_lock<boost::mutex> lock(mutex);
BOOST_TEST(threads2.is_this_thread_in());
std::cout << "count = " << ++count << std::endl;
}
int main()
{
{
boost::thread_group threads;
for (int i = 0; i < 10; ++i)
for (int i = 0; i < 3; ++i)
threads.create_thread(&increment_count);
threads.join_all();
}
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
{
boost::thread_group threads;
for (int i = 0; i < 3; ++i)
threads.create_thread(&increment_count);
threads.interrupt_all();
threads.join_all();
}
#endif
{
boost::thread_group threads;
boost::thread* th = new boost::thread(&increment_count);
threads.add_thread(th);
BOOST_TEST(! threads.is_this_thread_in());
threads.join_all();
}
{
boost::thread_group threads;
boost::thread* th = new boost::thread(&increment_count);
threads.add_thread(th);
BOOST_TEST(threads.is_thread_in(th));
threads.remove_thread(th);
BOOST_TEST(! threads.is_thread_in(th));
th->join();
delete th;
}
{
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::thread* th2 = new boost::thread(&increment_count_2);
threads2.add_thread(th2);
}
threads2.join_all();
}
return boost::report_errors();
}

57
example/thread_guard.cpp Normal file
View File

@@ -0,0 +1,57 @@
// (C) Copyright 2009-2012 Anthony Williams
// (C) Copyright 2012 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <string>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/thread_guard.hpp>
void do_something(int& i)
{
++i;
}
struct func
{
int& i;
func(int& i_):i(i_){}
void operator()()
{
for(unsigned j=0;j<1000000;++j)
{
do_something(i);
}
}
private:
func& operator=(func const&);
};
void do_something_in_current_thread()
{}
void f()
{
int some_local_state;
func my_func(some_local_state);
boost::thread t(my_func);
boost::thread_guard<> g(t);
do_something_in_current_thread();
}
int main()
{
f();
return 0;
}

73
example/thread_pool.cpp Normal file
View File

@@ -0,0 +1,73 @@
// Copyright (C) 2012-2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/thread/detail/log.hpp>
#include <boost/thread/executors/basic_thread_pool.hpp>
#include <boost/assert.hpp>
#include <string>
void p1()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " P1" << BOOST_THREAD_END_LOG;
}
void p2()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " P2" << BOOST_THREAD_END_LOG;
}
void submit_some(boost::basic_thread_pool& tp) {
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
}
int main()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " <MAIN" << BOOST_THREAD_END_LOG;
{
try
{
boost::basic_thread_pool tp;
submit_some(tp);
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}

View File

@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/thread.hpp>
@@ -24,10 +24,11 @@ void thread_proc()
increment();
int* p = value.get();
assert(*p == i+1);
(void)(p);
}
}
int main(int argc, char* argv[])
int main()
{
boost::thread_group threads;
for (int i=0; i<5; ++i)

View File

@@ -0,0 +1,75 @@
// Copyright (C) 2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_USES_LOG_THREAD_ID
#if ! defined BOOST_NO_CXX11_DECLTYPE
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/thread/detail/log.hpp>
#include <boost/thread/executors/loop_executor.hpp>
#include <boost/assert.hpp>
#include <boost/thread/thread_only.hpp>
#include <string>
void p1()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " P1" << BOOST_THREAD_END_LOG;
}
void p2()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " P2" << BOOST_THREAD_END_LOG;
}
void submit_some(boost::loop_executor& tp) {
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
tp.submit(&p1);
tp.submit(&p2);
}
int main()
{
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << " <MAIN" << BOOST_THREAD_END_LOG;
{
try
{
boost::loop_executor tp;
submit_some(tp);
tp.run_queued_closures();
submit_some(tp);
tp.run_queued_closures();
}
catch (std::exception& ex)
{
BOOST_THREAD_LOG
<< "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
return 1;
}
catch (...)
{
BOOST_THREAD_LOG
<< " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
return 2;
}
}
BOOST_THREAD_LOG
<< boost::this_thread::get_id() << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
}

View File

@@ -0,0 +1,53 @@
// (C) Copyright 2013 Ruslan Baratov
// Copyright (C) 2014 Vicente Botet
//
// 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)
// See www.boost.org/libs/thread for documentation.
#define BOOST_THREAD_VERSION 4
#include <iostream> // std::cout
#include <boost/thread/scoped_thread.hpp>
#include <boost/thread/with_lock_guard.hpp>
boost::mutex m; // protection for 'x' and 'std::cout'
int x;
#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700)
void print_x() {
++x;
std::cout << "x = " << x << std::endl;
}
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(m, print_x);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
}
}
#else
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(
m,
[]() {
++x;
std::cout << "x = " << x << std::endl;
}
);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
}
}
#endif
int main() {
#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700)
std::cout << "(no lambdas)" << std::endl;
#endif
boost::scoped_thread<> thread_1((boost::thread(job)));
boost::scoped_thread<> thread_2((boost::thread(job)));
boost::scoped_thread<> thread_3((boost::thread(job)));
return 0;
}

View File

@@ -1,16 +1,18 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/thread.hpp>
#define BOOST_THREAD_VERSION 2
#include <boost/thread/thread_only.hpp>
#include <boost/thread/xtime.hpp>
int main(int argc, char* argv[])
int main()
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1;
boost::thread::sleep(xt); // Sleep for 1 second
}

View File

@@ -0,0 +1,19 @@
// Copyright (C) 2013 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if defined(BOOST_INTEL)
#pragma pop_macro("atomic_compare_exchange")
#pragma pop_macro("atomic_compare_exchange_explicit")
#pragma pop_macro("atomic_exchange")
#pragma pop_macro("atomic_exchange_explicit")
#pragma pop_macro("atomic_is_lock_free")
#pragma pop_macro("atomic_load")
#pragma pop_macro("atomic_load_explicit")
#pragma pop_macro("atomic_store")
#pragma pop_macro("atomic_store_explicit")
#endif // #if defined(BOOST_INTEL)

View File

@@ -0,0 +1,39 @@
// Copyright (C) 2013 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if defined(BOOST_INTEL)
#pragma push_macro("atomic_compare_exchange")
#undef atomic_compare_exchange
#pragma push_macro("atomic_compare_exchange_explicit")
#undef atomic_compare_exchange_explicit
#pragma push_macro("atomic_exchange")
#undef atomic_exchange
#pragma push_macro("atomic_exchange_explicit")
#undef atomic_exchange_explicit
#pragma push_macro("atomic_is_lock_free")
#undef atomic_is_lock_free
#pragma push_macro("atomic_load")
#undef atomic_load
#pragma push_macro("atomic_load_explicit")
#undef atomic_load_explicit
#pragma push_macro("atomic_store")
#undef atomic_store
#pragma push_macro("atomic_store_explicit")
#undef atomic_store_explicit
#endif // #if defined(BOOST_INTEL)

View File

@@ -1,63 +1,254 @@
// Copyright (C) 2002-2003
// David Moore, William E. Kempf
// Copyright (C) 2007-8 Anthony Williams
// (C) Copyright 2013 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_BARRIER_JDM030602_HPP
#define BOOST_BARRIER_JDM030602_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/thread/detail/delete.hpp>
#include <boost/throw_exception.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_types.hpp>
#include <boost/thread/condition_variable.hpp>
#include <string>
#include <stdexcept>
#include <boost/thread/detail/nullary_function.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace thread_detail
{
typedef detail::nullary_function<void()> void_completion_function;
typedef detail::nullary_function<size_t()> size_completion_function;
class barrier
struct default_barrier_reseter
{
public:
barrier(unsigned int count)
: m_threshold(count), m_count(count), m_generation(0)
{
if (count == 0)
boost::throw_exception(std::invalid_argument("count cannot be zero."));
}
bool wait()
{
boost::mutex::scoped_lock lock(m_mutex);
unsigned int gen = m_generation;
if (--m_count == 0)
{
m_generation++;
m_count = m_threshold;
m_cond.notify_all();
return true;
}
unsigned int size_;
default_barrier_reseter(unsigned int size) :
size_(size)
{
}
BOOST_THREAD_MOVABLE(default_barrier_reseter)
//BOOST_THREAD_COPYABLE_AND_MOVABLE(default_barrier_reseter)
while (gen == m_generation)
m_cond.wait(lock);
return false;
}
default_barrier_reseter(default_barrier_reseter const& other) BOOST_NOEXCEPT :
size_(other.size_)
{
}
default_barrier_reseter(BOOST_THREAD_RV_REF(default_barrier_reseter) other) BOOST_NOEXCEPT :
size_(BOOST_THREAD_RV(other).size_)
{
}
private:
mutex m_mutex;
condition_variable m_cond;
unsigned int m_threshold;
unsigned int m_count;
unsigned int m_generation;
unsigned int operator()()
{
return size_;
}
};
} // namespace boost
struct void_functor_barrier_reseter
{
unsigned int size_;
void_completion_function fct_;
template <typename F>
void_functor_barrier_reseter(unsigned int size, BOOST_THREAD_RV_REF(F) funct)
: size_(size), fct_(boost::move(funct))
{}
template <typename F>
void_functor_barrier_reseter(unsigned int size, F& funct)
: size_(size), fct_(funct)
{}
BOOST_THREAD_MOVABLE(void_functor_barrier_reseter)
//BOOST_THREAD_COPYABLE_AND_MOVABLE(void_functor_barrier_reseter)
void_functor_barrier_reseter(void_functor_barrier_reseter const& other) BOOST_NOEXCEPT :
size_(other.size_), fct_(other.fct_)
{
}
void_functor_barrier_reseter(BOOST_THREAD_RV_REF(void_functor_barrier_reseter) other) BOOST_NOEXCEPT :
size_(BOOST_THREAD_RV(other).size_), fct_(BOOST_THREAD_RV(other).fct_)
//size_(BOOST_THREAD_RV(other).size_), fct_(boost::move(BOOST_THREAD_RV(other).fct_))
{
}
unsigned int operator()()
{
fct_();
return size_;
}
};
struct void_fct_ptr_barrier_reseter
{
unsigned int size_;
void(*fct_)();
void_fct_ptr_barrier_reseter(unsigned int size, void(*funct)()) :
size_(size), fct_(funct)
{
}
BOOST_THREAD_MOVABLE(void_fct_ptr_barrier_reseter)
//BOOST_THREAD_COPYABLE_AND_MOVABLE(void_fct_ptr_barrier_reseter)
void_fct_ptr_barrier_reseter(void_fct_ptr_barrier_reseter const& other) BOOST_NOEXCEPT :
size_(other.size_), fct_(other.fct_)
{
}
void_fct_ptr_barrier_reseter(BOOST_THREAD_RV_REF(void_fct_ptr_barrier_reseter) other) BOOST_NOEXCEPT :
size_(BOOST_THREAD_RV(other).size_), fct_(BOOST_THREAD_RV(other).fct_)
{
}
unsigned int operator()()
{
fct_();
return size_;
}
};
}
//BOOST_THREAD_DCL_MOVABLE(thread_detail::default_barrier_reseter)
//BOOST_THREAD_DCL_MOVABLE(thread_detail::void_functor_barrier_reseter)
//BOOST_THREAD_DCL_MOVABLE(thread_detail::void_fct_ptr_barrier_reseter)
class barrier
{
static inline unsigned int check_counter(unsigned int count)
{
if (count == 0) boost::throw_exception(
thread_exception(system::errc::invalid_argument, "barrier constructor: count cannot be zero."));
return count;
}
struct dummy
{
};
public:
BOOST_THREAD_NO_COPYABLE( barrier)
explicit barrier(unsigned int count) :
m_count(check_counter(count)), m_generation(0), fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count)))
{
}
template <typename F>
barrier(
unsigned int count,
BOOST_THREAD_RV_REF(F) funct,
typename enable_if<
typename is_void<typename result_of<F()>::type>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
m_generation(0),
fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_functor_barrier_reseter(count,
boost::move(funct)))
)
{
}
template <typename F>
barrier(
unsigned int count,
F &funct,
typename enable_if<
typename is_void<typename result_of<F()>::type>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
m_generation(0),
fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_functor_barrier_reseter(count,
funct))
)
{
}
template <typename F>
barrier(
unsigned int count,
BOOST_THREAD_RV_REF(F) funct,
typename enable_if<
typename is_same<typename result_of<F()>::type, unsigned int>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
m_generation(0),
fct_(boost::move(funct))
{
}
template <typename F>
barrier(
unsigned int count,
F& funct,
typename enable_if<
typename is_same<typename result_of<F()>::type, unsigned int>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
m_generation(0),
fct_(funct)
{
}
barrier(unsigned int count, void(*funct)()) :
m_count(check_counter(count)), m_generation(0),
fct_(funct
? BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_fct_ptr_barrier_reseter(count, funct))))
: BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count))))
)
{
}
barrier(unsigned int count, unsigned int(*funct)()) :
m_count(check_counter(count)), m_generation(0),
fct_(funct
? BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(funct))
: BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count))))
)
{
}
bool wait()
{
boost::unique_lock < boost::mutex > lock(m_mutex);
unsigned int gen = m_generation;
if (--m_count == 0)
{
m_generation++;
m_count = static_cast<unsigned int>(fct_());
BOOST_ASSERT(m_count != 0);
lock.unlock();
m_cond.notify_all();
return true;
}
while (gen == m_generation)
m_cond.wait(lock);
return false;
}
void count_down_and_wait()
{
wait();
}
private:
mutex m_mutex;
condition_variable m_cond;
unsigned int m_count;
unsigned int m_generation;
thread_detail::size_completion_function fct_;
};
} // namespace boost
#include <boost/config/abi_suffix.hpp>

View File

@@ -0,0 +1,59 @@
// (C) Copyright 2013,2015 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)
#ifndef BOOST_THREAD_CALL_CONTEXT_HPP
#define BOOST_THREAD_CALL_CONTEXT_HPP
#include <boost/thread/detail/config.hpp>
#if defined BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/thread.hpp>
#endif
#include <boost/current_function.hpp>
#include <boost/io/ios_state.hpp>
#include <iomanip>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
struct caller_context_t
{
const char * filename;
unsigned lineno;
const char * func;
caller_context_t(const char * filename, unsigned lineno, const char * func) :
filename(filename), lineno(lineno), func(func)
{
}
};
#define BOOST_CONTEXTOF boost::caller_context_t(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
template <typename OStream>
OStream& operator<<(OStream& os, caller_context_t const& ctx)
{
#if defined BOOST_THREAD_USES_LOG_THREAD_ID
{
io::ios_flags_saver ifs( os );
os << std::left << std::setw(14) << boost::this_thread::get_id() << " ";
}
#endif
{
io::ios_flags_saver ifs(os);
os << std::setw(50) << ctx.filename << "["
<< std::setw(4) << std::right << std::dec<< ctx.lineno << "] ";
#if defined BOOST_THREAD_USES_LOG_CURRENT_FUNCTION
os << ctx.func << " " ;
#endif
}
return os;
}
}
#include <boost/config/abi_suffix.hpp>
#endif // header

View File

@@ -0,0 +1,225 @@
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright 2013 Vicente J. Botet Escriba
#ifndef BOOST_THREAD_COMPLETION_LATCH_HPP
#define BOOST_THREAD_COMPLETION_LATCH_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/delete.hpp>
#include <boost/thread/detail/counter.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_types.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/assert.hpp>
//#include <boost/thread/detail/nullary_function.hpp>
#include <boost/thread/csbl/functional.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace thread_detail
{
void noop()
{
}
}
class completion_latch
{
public:
/// the implementation defined completion function type
//typedef detail::nullary_function<void()> completion_function;
typedef csbl::function<void()> completion_function;
/// noop completion function factory
static completion_function noop()
{
return completion_function(&thread_detail::noop);
}
private:
struct around_wait;
friend struct around_wait;
struct around_wait
{
completion_latch &that_;
boost::unique_lock<boost::mutex> &lk_;
around_wait(completion_latch &that, boost::unique_lock<boost::mutex> &lk)
: that_(that), lk_(lk)
{
that_.leavers_.cond_.wait(lk, detail::counter_is_zero(that_.leavers_));
that_.waiters_.inc_and_notify_all();
that_.leavers_.cond_.wait(lk, detail::counter_is_not_zero(that_.leavers_));
}
~around_wait()
{
that_.waiters_.dec_and_notify_all();
}
};
bool count_down(unique_lock<mutex> &lk)
{
BOOST_ASSERT(count_ > 0);
if (--count_ == 0)
{
waiters_.cond_.wait(lk, detail::counter_is_not_zero(waiters_));
leavers_.assign_and_notify_all(waiters_);
count_.cond_.notify_all();
waiters_.cond_.wait(lk, detail::counter_is_zero(waiters_));
leavers_.assign_and_notify_all(0);
lk.unlock();
funct_();
return true;
}
return false;
}
public:
BOOST_THREAD_NO_COPYABLE( completion_latch )
/// Constructs a latch with a given count.
completion_latch(std::size_t count) :
count_(count), funct_(noop()), waiters_(0), leavers_(0)
{
}
/// Constructs a latch with a given count and a completion function.
template <typename F>
completion_latch(std::size_t count, BOOST_THREAD_RV_REF(F) funct) :
count_(count),
funct_(boost::move(funct)),
waiters_(0),
leavers_(0)
{
}
completion_latch(std::size_t count, void(*funct)()) :
count_(count), funct_(funct), waiters_(0), leavers_(0)
{
}
///
~completion_latch()
{
}
/// Blocks until the latch has counted down to zero.
void wait()
{
boost::unique_lock<boost::mutex> lk(mutex_);
around_wait aw(*this, lk);
count_.cond_.wait(lk, detail::counter_is_zero(count_));
}
/// @return true if the internal counter is already 0, false otherwise
bool try_wait()
{
boost::unique_lock<boost::mutex> lk(mutex_);
around_wait aw(*this, lk);
return (count_ == 0);
}
/// try to wait for a specified amount of time
/// @return whether there is a timeout or not.
template <class Rep, class Period>
cv_status wait_for(const chrono::duration<Rep, Period>& rel_time)
{
boost::unique_lock<boost::mutex> lk(mutex_);
around_wait aw(*this, lk);
return count_.cond_.wait_for(lk, rel_time, detail::counter_is_zero(count_))
? cv_status::no_timeout
: cv_status::timeout;
}
/// try to wait until the specified time_point is reached
/// @return whether there is a timeout or not.
template <class Clock, class Duration>
cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time)
{
boost::unique_lock<boost::mutex> lk(mutex_);
around_wait aw(*this, lk);
return count_.cond_.wait_until(lk, abs_time, detail::counter_is_zero(count_))
? cv_status::no_timeout
: cv_status::timeout;
}
/// Decrement the count and notify anyone waiting if we reach zero.
/// @Requires count must be greater than 0
void count_down()
{
unique_lock<mutex> lk(mutex_);
count_down(lk);
}
void signal()
{
count_down();
}
/// Decrement the count and notify anyone waiting if we reach zero.
/// Blocks until the latch has counted down to zero.
/// @Requires count must be greater than 0
void count_down_and_wait()
{
boost::unique_lock<boost::mutex> lk(mutex_);
if (count_down(lk))
{
return;
}
around_wait aw(*this, lk);
count_.cond_.wait(lk, detail::counter_is_zero(count_));
}
void sync()
{
count_down_and_wait();
}
/// Reset the counter
/// #Requires This method may only be invoked when there are no other threads currently inside the count_down_and_wait() method.
void reset(std::size_t count)
{
boost::lock_guard<boost::mutex> lk(mutex_);
//BOOST_ASSERT(count_ == 0);
count_ = count;
}
/// Resets the latch with the new completion function.
/// The next time the internal count reaches 0, this function will be invoked.
/// This completion function may only be invoked when there are no other threads
/// currently inside the count_down and wait related functions.
/// It may also be invoked from within the registered completion function.
/// @Returns the old completion function if any or noop if
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
template <typename F>
completion_function then(BOOST_THREAD_RV_REF(F) funct)
{
boost::lock_guard<boost::mutex> lk(mutex_);
completion_function tmp(funct_);
funct_ = boost::move(funct);
return tmp;
}
#endif
completion_function then(void(*funct)())
{
boost::lock_guard<boost::mutex> lk(mutex_);
completion_function tmp(funct_);
funct_ = completion_function(funct);
return tmp;
}
private:
mutex mutex_;
detail::counter count_;
completion_function funct_;
detail::counter waiters_;
detail::counter leavers_;
};
} // namespace boost
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,209 @@
#ifndef BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP
#define BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/concurrent_queues/deque_base.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <typename Queue>
class deque_adaptor_copyable_only :
public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
deque_adaptor_copyable_only() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void push_back(const value_type& x) { queue.push_back(x); }
void pull_front(value_type& x) { queue.pull_front(x); };
value_type pull_front() { return queue.pull_front(); }
queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); }
queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); }
queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); }
queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
};
template <typename Queue>
class deque_adaptor_movable_only :
public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
deque_adaptor_movable_only() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void pull_front(value_type& x) { queue.pull_front(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull_front() { return queue.pull_front(); }
queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); }
queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); }
queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); }
queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); }
};
template <typename Queue>
class deque_adaptor_copyable_and_movable :
public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
deque_adaptor_copyable_and_movable() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void push_back(const value_type& x) { queue.push_back(x); }
void pull_front(value_type& x) { queue.pull_front(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull_front() { return queue.pull_front(); }
queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); }
queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); }
queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); }
queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); }
queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); }
queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); }
queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); }
};
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__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // __GNUC__
#elif defined _MSC_VER
#if _MSC_VER < 1700
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // _MSC_VER
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif
#else
bool Copyable = is_copy_constructible<T>::value,
bool Movable = has_move_emulation_enabled<T>::value
#endif
>
struct deque_adaptor;
template <class Q, class T>
struct deque_adaptor<Q, T, true, true> {
typedef deque_adaptor_copyable_and_movable<Q> type;
};
template <class Q, class T>
struct deque_adaptor<Q, T, true, false> {
typedef deque_adaptor_copyable_only<Q> type;
};
template <class Q, class T>
struct deque_adaptor<Q, T, false, true> {
typedef deque_adaptor_movable_only<Q> type;
};
}
template <typename Queue>
class deque_adaptor :
public detail::deque_adaptor<Queue, typename Queue::value_type>::type
{
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
virtual ~deque_adaptor() {};
};
}
using concurrent::deque_adaptor;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,202 @@
#ifndef BOOST_THREAD_CONCURRENT_DEQUE_BASE_HPP
#define BOOST_THREAD_CONCURRENT_DEQUE_BASE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_copy_constructible.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <typename ValueType, class SizeType>
class deque_base_copyable_only
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~deque_base_copyable_only() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void push_back(const value_type& x) = 0;
virtual void pull_front(value_type&) = 0;
virtual value_type pull_front() = 0;
virtual queue_op_status try_push_back(const value_type& x) = 0;
virtual queue_op_status try_pull_front(value_type&) = 0;
virtual queue_op_status nonblocking_push_back(const value_type& x) = 0;
virtual queue_op_status nonblocking_pull_front(value_type&) = 0;
virtual queue_op_status wait_push_back(const value_type& x) = 0;
virtual queue_op_status wait_pull_front(value_type& elem) = 0;
};
template <typename ValueType, class SizeType>
class deque_base_movable_only
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~deque_base_movable_only() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void pull_front(value_type&) = 0;
// enable_if is_nothrow_movable<value_type>
virtual value_type pull_front() = 0;
virtual queue_op_status try_pull_front(value_type&) = 0;
virtual queue_op_status nonblocking_pull_front(value_type&) = 0;
virtual queue_op_status wait_pull_front(value_type& elem) = 0;
virtual void push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
};
template <typename ValueType, class SizeType>
class deque_base_copyable_and_movable
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~deque_base_copyable_and_movable() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void push_back(const value_type& x) = 0;
virtual void pull_front(value_type&) = 0;
// enable_if is_nothrow_copy_movable<value_type>
virtual value_type pull_front() = 0;
virtual queue_op_status try_push_back(const value_type& x) = 0;
virtual queue_op_status try_pull_front(value_type&) = 0;
virtual queue_op_status nonblocking_push_back(const value_type& x) = 0;
virtual queue_op_status nonblocking_pull_front(value_type&) = 0;
virtual queue_op_status wait_push_back(const value_type& x) = 0;
virtual queue_op_status wait_pull_front(value_type& elem) = 0;
virtual void push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
};
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__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // __GNUC__
#elif defined _MSC_VER
#if _MSC_VER < 1700
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // _MSC_VER
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif
#else
bool Copyable = is_copy_constructible<T>::value,
bool Movable = has_move_emulation_enabled<T>::value
#endif
>
struct deque_base;
template <class T, class ST>
struct deque_base<T, ST, true, true> {
typedef deque_base_copyable_and_movable<T, ST> type;
};
template <class T, class ST>
struct deque_base<T, ST, true, false> {
typedef deque_base_copyable_only<T, ST> type;
};
template <class T, class ST>
struct deque_base<T, ST, false, true> {
typedef deque_base_movable_only<T, ST> type;
};
}
template <class ValueType, class SizeType=std::size_t>
class deque_base :
public detail::deque_base<ValueType, SizeType>::type
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~deque_base() {};
};
}
using concurrent::deque_base;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,165 @@
#ifndef BOOST_THREAD_QUEUE_VIEWS_HPP
#define BOOST_THREAD_QUEUE_VIEWS_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/concurrent_queues/deque_base.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
template <typename Queue>
class deque_back_view
{
Queue* queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
deque_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
// Observers
bool empty() const { return queue->empty(); }
bool full() const { return queue->full(); }
size_type size() const { return queue->size(); }
bool closed() const { return queue->closed(); }
// Modifiers
void close() { queue->close(); }
void push(const value_type& x) { queue->push_back(x); }
void pull(value_type& x) { queue->pull_back(x); }
// enable_if is_nothrow_copy_movable<value_type>
value_type pull() { return queue->pull_back(); }
queue_op_status try_push(const value_type& x) { return queue->try_push_back(x); }
queue_op_status try_pull(value_type& x) { return queue->try_pull_back(x); }
queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_back(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_back(x); }
queue_op_status wait_push(const value_type& x) { return queue->wait_push_back(x); }
queue_op_status wait_pull(value_type& x) { return queue->wait_pull_back(x); }
void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_back(boost::move(x)); }
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_back(boost::move(x)); }
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_back(boost::move(x)); }
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_back(boost::move(x)); }
};
template <typename Queue>
class deque_front_view
{
Queue* queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
deque_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
// Observers
bool empty() const { return queue->empty(); }
bool full() const { return queue->full(); }
size_type size() const { return queue->size(); }
bool closed() const { return queue->closed(); }
// Modifiers
void close() { queue->close(); }
void push(const value_type& x) { queue->push_front(x); }
void pull(value_type& x) { queue->pull_front(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull() { return queue->pull_front(); }
queue_op_status try_push(const value_type& x) { return queue->try_push_front(x); }
queue_op_status try_pull(value_type& x) { return queue->try_pull_front(x); }
queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_front(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_front(x); }
queue_op_status wait_push(const value_type& x) { return queue->wait_push_front(x); }
queue_op_status wait_pull(value_type& x) { return queue->wait_pull_front(x); }
void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_front(forward<value_type>(x)); }
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_front(forward<value_type>(x)); }
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_front(forward<value_type>(x)); }
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_front(forward<value_type>(x)); }
};
#if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES
template <class T>
using deque_back = deque_back_view<deque_base<T> > ;
template <class T>
using deque_front = deque_front_view<deque_base<T> > ;
#else
template <class T>
struct deque_back : deque_back_view<deque_base<T> >
{
typedef deque_back_view<deque_base<T> > base_type;
deque_back(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
};
template <class T>
struct deque_front : deque_front_view<deque_base<T> >
{
typedef deque_front_view<deque_base<T> > base_type;
deque_front(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
};
#endif
// template <class Queue>
// deque_back_view<Queue> back(Queue & q) { return deque_back_view<Queue>(q); }
// template <class Queue>
// deque_front_view<Queue> front(Queue & q) { return deque_front_view<Queue>(q); }
//#if 0
// template <class T>
// deque_back<T> back(deque_base<T> & q) { return deque_back<T>(q); }
// template <class T>
// deque_front<T> front(deque_base<T> & q) { return deque_front<T>(q); }
//#else
// template <class T>
// typename deque_back<T>::type back(deque_base<T> & q) { return typename deque_back<T>::type(q); }
// template <class T>
// typename deque_front<T>::type front(deque_base<T> & q) { return typename deque_front<T>::type(q); }
//#endif
}
using concurrent::deque_back_view;
using concurrent::deque_front_view;
using concurrent::deque_back;
using concurrent::deque_front;
//using concurrent::back;
//using concurrent::front;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,223 @@
#ifndef BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_DEQUE_BASE_HPP
#define BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_DEQUE_BASE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2013-2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
#include <boost/throw_exception.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <class ValueType, class Queue>
class sync_deque_base
{
public:
typedef ValueType value_type;
typedef Queue underlying_queue_type;
typedef typename Queue::size_type size_type;
typedef queue_op_status op_status;
typedef typename chrono::steady_clock clock;
typedef typename clock::duration duration;
typedef typename clock::time_point time_point;
// Constructors/Assignment/Destructors
BOOST_THREAD_NO_COPYABLE(sync_deque_base)
inline sync_deque_base();
//template <typename Range>
//inline explicit sync_deque(Range range);
inline ~sync_deque_base();
// Observers
inline bool empty() const;
inline bool full() const;
inline size_type size() const;
inline bool closed() const;
// Modifiers
inline void close();
inline underlying_queue_type underlying_queue() {
lock_guard<mutex> lk(mtx_);
return boost::move(data_);
}
protected:
mutable mutex mtx_;
condition_variable not_empty_;
underlying_queue_type data_;
bool closed_;
inline bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
{
return data_.empty();
}
inline bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return data_.empty();
}
inline size_type size(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return data_.size();
}
inline bool closed(unique_lock<mutex>& lk) const;
inline bool closed(lock_guard<mutex>& lk) const;
inline void throw_if_closed(unique_lock<mutex>&);
inline void throw_if_closed(lock_guard<mutex>&);
inline void wait_until_not_empty(unique_lock<mutex>& lk);
inline bool wait_until_not_empty_or_closed(unique_lock<mutex>& lk);
inline queue_op_status wait_until_not_empty_until(unique_lock<mutex>& lk, time_point const&);
inline void notify_not_empty_if_needed(unique_lock<mutex>& )
{
not_empty_.notify_one();
}
inline void notify_not_empty_if_needed(lock_guard<mutex>& )
{
not_empty_.notify_one();
}
};
template <class ValueType, class Queue>
sync_deque_base<ValueType, Queue>::sync_deque_base() :
data_(), closed_(false)
{
BOOST_ASSERT(data_.empty());
}
template <class ValueType, class Queue>
sync_deque_base<ValueType, Queue>::~sync_deque_base()
{
}
template <class ValueType, class Queue>
void sync_deque_base<ValueType, Queue>::close()
{
{
lock_guard<mutex> lk(mtx_);
closed_ = true;
}
not_empty_.notify_all();
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::closed() const
{
lock_guard<mutex> lk(mtx_);
return closed(lk);
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::closed(unique_lock<mutex>&) const
{
return closed_;
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::closed(lock_guard<mutex>&) const
{
return closed_;
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::empty() const
{
lock_guard<mutex> lk(mtx_);
return empty(lk);
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::full() const
{
return false;
}
template <class ValueType, class Queue>
typename sync_deque_base<ValueType, Queue>::size_type sync_deque_base<ValueType, Queue>::size() const
{
lock_guard<mutex> lk(mtx_);
return size(lk);
}
template <class ValueType, class Queue>
void sync_deque_base<ValueType, Queue>::throw_if_closed(unique_lock<mutex>& lk)
{
if (closed(lk))
{
BOOST_THROW_EXCEPTION( sync_deque_is_closed() );
}
}
template <class ValueType, class Queue>
void sync_deque_base<ValueType, Queue>::throw_if_closed(lock_guard<mutex>& lk)
{
if (closed(lk))
{
BOOST_THROW_EXCEPTION( sync_deque_is_closed() );
}
}
template <class ValueType, class Queue>
void sync_deque_base<ValueType, Queue>::wait_until_not_empty(unique_lock<mutex>& lk)
{
for (;;)
{
if (! empty(lk)) break;
throw_if_closed(lk);
not_empty_.wait(lk);
}
}
template <class ValueType, class Queue>
bool sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
{
for (;;)
{
if (! empty(lk)) break;
if (closed(lk)) return true;
not_empty_.wait(lk);
}
return false;
}
template <class ValueType, class Queue>
queue_op_status sync_deque_base<ValueType, Queue>::wait_until_not_empty_until(unique_lock<mutex>& lk, time_point const&tp)
{
for (;;)
{
if (! empty(lk)) return queue_op_status::success;
throw_if_closed(lk);
if (not_empty_.wait_until(lk, tp) == cv_status::timeout ) return queue_op_status::timeout;
}
}
} // detail
} // concurrent
} // boost
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,223 @@
#ifndef BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_QUEUE_BASE_HPP
#define BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_QUEUE_BASE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2013-2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
#include <boost/throw_exception.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <class ValueType, class Queue>
class sync_queue_base
{
public:
typedef ValueType value_type;
typedef Queue underlying_queue_type;
typedef typename Queue::size_type size_type;
typedef queue_op_status op_status;
typedef typename chrono::steady_clock clock;
typedef typename clock::duration duration;
typedef typename clock::time_point time_point;
// Constructors/Assignment/Destructors
BOOST_THREAD_NO_COPYABLE(sync_queue_base)
inline sync_queue_base();
//template <typename Range>
//inline explicit sync_queue(Range range);
inline ~sync_queue_base();
// Observers
inline bool empty() const;
inline bool full() const;
inline size_type size() const;
inline bool closed() const;
// Modifiers
inline void close();
inline underlying_queue_type underlying_queue() {
lock_guard<mutex> lk(mtx_);
return boost::move(data_);
}
protected:
mutable mutex mtx_;
condition_variable not_empty_;
underlying_queue_type data_;
bool closed_;
inline bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
{
return data_.empty();
}
inline bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return data_.empty();
}
inline size_type size(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return data_.size();
}
inline bool closed(unique_lock<mutex>& lk) const;
inline bool closed(lock_guard<mutex>& lk) const;
inline void throw_if_closed(unique_lock<mutex>&);
inline void throw_if_closed(lock_guard<mutex>&);
inline void wait_until_not_empty(unique_lock<mutex>& lk);
inline bool wait_until_not_empty_or_closed(unique_lock<mutex>& lk);
inline queue_op_status wait_until_not_empty_until(unique_lock<mutex>& lk, time_point const&);
inline void notify_not_empty_if_needed(unique_lock<mutex>& )
{
not_empty_.notify_one();
}
inline void notify_not_empty_if_needed(lock_guard<mutex>& )
{
not_empty_.notify_one();
}
};
template <class ValueType, class Queue>
sync_queue_base<ValueType, Queue>::sync_queue_base() :
data_(), closed_(false)
{
BOOST_ASSERT(data_.empty());
}
template <class ValueType, class Queue>
sync_queue_base<ValueType, Queue>::~sync_queue_base()
{
}
template <class ValueType, class Queue>
void sync_queue_base<ValueType, Queue>::close()
{
{
lock_guard<mutex> lk(mtx_);
closed_ = true;
}
not_empty_.notify_all();
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::closed() const
{
lock_guard<mutex> lk(mtx_);
return closed(lk);
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::closed(unique_lock<mutex>&) const
{
return closed_;
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::closed(lock_guard<mutex>&) const
{
return closed_;
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::empty() const
{
lock_guard<mutex> lk(mtx_);
return empty(lk);
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::full() const
{
return false;
}
template <class ValueType, class Queue>
typename sync_queue_base<ValueType, Queue>::size_type sync_queue_base<ValueType, Queue>::size() const
{
lock_guard<mutex> lk(mtx_);
return size(lk);
}
template <class ValueType, class Queue>
void sync_queue_base<ValueType, Queue>::throw_if_closed(unique_lock<mutex>& lk)
{
if (closed(lk))
{
BOOST_THROW_EXCEPTION( sync_queue_is_closed() );
}
}
template <class ValueType, class Queue>
void sync_queue_base<ValueType, Queue>::throw_if_closed(lock_guard<mutex>& lk)
{
if (closed(lk))
{
BOOST_THROW_EXCEPTION( sync_queue_is_closed() );
}
}
template <class ValueType, class Queue>
void sync_queue_base<ValueType, Queue>::wait_until_not_empty(unique_lock<mutex>& lk)
{
for (;;)
{
if (! empty(lk)) break;
throw_if_closed(lk);
not_empty_.wait(lk);
}
}
template <class ValueType, class Queue>
bool sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
{
for (;;)
{
if (! empty(lk)) break;
if (closed(lk)) return true;
not_empty_.wait(lk);
}
return false;
}
template <class ValueType, class Queue>
queue_op_status sync_queue_base<ValueType, Queue>::wait_until_not_empty_until(unique_lock<mutex>& lk, time_point const&tp)
{
for (;;)
{
if (! empty(lk)) return queue_op_status::success;
throw_if_closed(lk);
if (not_empty_.wait_until(lk, tp) == cv_status::timeout ) return queue_op_status::timeout;
}
}
} // detail
} // concurrent
} // boost
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,209 @@
#ifndef BOOST_THREAD_QUEUE_ADAPTOR_HPP
#define BOOST_THREAD_QUEUE_ADAPTOR_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/concurrent_queues/queue_base.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <typename Queue>
class queue_adaptor_copyable_only :
public boost::queue_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
queue_adaptor_copyable_only() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void push(const value_type& x) { queue.push(x); }
void pull(value_type& x) { queue.pull(x); };
value_type pull() { return queue.pull(); }
queue_op_status try_push(const value_type& x) { return queue.try_push(x); }
queue_op_status try_pull(value_type& x) { return queue.try_pull(x); }
queue_op_status nonblocking_push(const value_type& x) { return queue.nonblocking_push(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); }
queue_op_status wait_push(const value_type& x) { return queue.wait_push(x); }
queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); }
};
template <typename Queue>
class queue_adaptor_movable_only :
public boost::queue_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
queue_adaptor_movable_only() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void pull(value_type& x) { queue.pull(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull() { return queue.pull(); }
queue_op_status try_pull(value_type& x) { return queue.try_pull(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); }
queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); }
void push(BOOST_THREAD_RV_REF(value_type) x) { queue.push(boost::move(x)); }
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push(boost::move(x)); }
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push(boost::move(x)); }
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push(boost::move(x)); }
};
template <typename Queue>
class queue_adaptor_copyable_and_movable :
public boost::queue_base<typename Queue::value_type, typename Queue::size_type>
{
Queue queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
queue_adaptor_copyable_and_movable() {}
// Observers
bool empty() const { return queue.empty(); }
bool full() const { return queue.full(); }
size_type size() const { return queue.size(); }
bool closed() const { return queue.closed(); }
// Modifiers
void close() { queue.close(); }
void push(const value_type& x) { queue.push(x); }
void pull(value_type& x) { queue.pull(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull() { return queue.pull(); }
queue_op_status try_push(const value_type& x) { return queue.try_push(x); }
queue_op_status try_pull(value_type& x) { return queue.try_pull(x); }
queue_op_status nonblocking_push(const value_type& x) { return queue.nonblocking_push(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); }
queue_op_status wait_push(const value_type& x) { return queue.wait_push(x); }
queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); }
void push(BOOST_THREAD_RV_REF(value_type) x) { queue.push(boost::move(x)); }
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push(boost::move(x)); }
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push(boost::move(x)); }
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push(boost::move(x)); }
};
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__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // __GNUC__
#elif defined _MSC_VER
#if _MSC_VER < 1700
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // _MSC_VER
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif
#else
bool Copyable = is_copy_constructible<T>::value,
bool Movable = has_move_emulation_enabled<T>::value
#endif
>
struct queue_adaptor;
template <class Q, class T>
struct queue_adaptor<Q, T, true, true> {
typedef queue_adaptor_copyable_and_movable<Q> type;
};
template <class Q, class T>
struct queue_adaptor<Q, T, true, false> {
typedef queue_adaptor_copyable_only<Q> type;
};
template <class Q, class T>
struct queue_adaptor<Q, T, false, true> {
typedef queue_adaptor_movable_only<Q> type;
};
}
template <typename Queue>
class queue_adaptor :
public detail::queue_adaptor<Queue, typename Queue::value_type>::type
{
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
virtual ~queue_adaptor() {};
};
}
using concurrent::queue_adaptor;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,202 @@
#ifndef BOOST_THREAD_QUEUE_BASE_HPP
#define BOOST_THREAD_QUEUE_BASE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_copy_constructible.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <typename ValueType, class SizeType>
class queue_base_copyable_only
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~queue_base_copyable_only() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void push(const value_type& x) = 0;
virtual void pull(value_type&) = 0;
virtual value_type pull() = 0;
virtual queue_op_status try_push(const value_type& x) = 0;
virtual queue_op_status try_pull(value_type&) = 0;
virtual queue_op_status nonblocking_push(const value_type& x) = 0;
virtual queue_op_status nonblocking_pull(value_type&) = 0;
virtual queue_op_status wait_push(const value_type& x) = 0;
virtual queue_op_status wait_pull(ValueType& elem) = 0;
};
template <typename ValueType, class SizeType>
class queue_base_movable_only
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~queue_base_movable_only() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void pull(value_type&) = 0;
// enable_if is_nothrow_movable<value_type>
virtual value_type pull() = 0;
virtual queue_op_status try_pull(value_type&) = 0;
virtual queue_op_status nonblocking_pull(value_type&) = 0;
virtual queue_op_status wait_pull(value_type& elem) = 0;
virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
};
template <typename ValueType, class SizeType>
class queue_base_copyable_and_movable
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~queue_base_copyable_and_movable() {};
// Observers
virtual bool empty() const = 0;
virtual bool full() const = 0;
virtual size_type size() const = 0;
virtual bool closed() const = 0;
// Modifiers
virtual void close() = 0;
virtual void push(const value_type& x) = 0;
virtual void pull(value_type&) = 0;
// enable_if is_nothrow_copy_movable<value_type>
virtual value_type pull() = 0;
virtual queue_op_status try_push(const value_type& x) = 0;
virtual queue_op_status try_pull(value_type&) = 0;
virtual queue_op_status nonblocking_push(const value_type& x) = 0;
virtual queue_op_status nonblocking_pull(value_type&) = 0;
virtual queue_op_status wait_push(const value_type& x) = 0;
virtual queue_op_status wait_pull(value_type& elem) = 0;
virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
};
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__)
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // __GNUC__
#elif defined _MSC_VER
#if _MSC_VER < 1700
bool Copyable = is_copy_constructible<T>::value,
bool Movable = true
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif // _MSC_VER
#else
bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
#endif
#else
bool Copyable = is_copy_constructible<T>::value,
bool Movable = has_move_emulation_enabled<T>::value
#endif
>
struct queue_base;
template <class T, class ST>
struct queue_base<T, ST, true, true> {
typedef queue_base_copyable_and_movable<T, ST> type;
};
template <class T, class ST>
struct queue_base<T, ST, true, false> {
typedef queue_base_copyable_only<T, ST> type;
};
template <class T, class ST>
struct queue_base<T, ST, false, true> {
typedef queue_base_movable_only<T, ST> type;
};
}
template <typename ValueType, class SizeType=std::size_t>
class queue_base :
public detail::queue_base<ValueType, SizeType>::type
{
public:
typedef ValueType value_type;
typedef SizeType size_type;
// Constructors/Assignment/Destructors
virtual ~queue_base() {};
};
}
using concurrent::queue_base;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,46 @@
#ifndef BOOST_THREAD_QUEUE_OP_STATUS_HPP
#define BOOST_THREAD_QUEUE_OP_STATUS_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
BOOST_SCOPED_ENUM_DECLARE_BEGIN(queue_op_status)
{ success = 0, empty, full, closed, busy, timeout, not_ready }
BOOST_SCOPED_ENUM_DECLARE_END(queue_op_status)
struct sync_queue_is_closed : std::exception
{
};
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
struct no_block_tag{};
BOOST_CONSTEXPR_OR_CONST no_block_tag no_block = {};
#endif
using concurrent::queue_op_status;
using concurrent::sync_queue_is_closed;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,144 @@
#ifndef BOOST_THREAD_QUEUE_VIEWS_HPP
#define BOOST_THREAD_QUEUE_VIEWS_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/concurrent_queues/queue_base.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
template <typename Queue>
class queue_back_view
{
Queue* queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
queue_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
// Observers
bool empty() const { return queue->empty(); }
bool full() const { return queue->full(); }
size_type size() const { return queue->size(); }
bool closed() const { return queue->closed(); }
// Modifiers
void close() { queue->close(); }
void push(const value_type& x) { queue->push(x); }
queue_op_status try_push(const value_type& x) { return queue->try_push(x); }
queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push(x); }
queue_op_status wait_push(const value_type& x) { return queue->wait_push(x); }
void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push(boost::move(x)); }
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push(boost::move(x)); }
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push(boost::move(x)); }
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push(boost::move(x)); }
};
template <typename Queue>
class queue_front_view
{
Queue* queue;
public:
typedef typename Queue::value_type value_type;
typedef typename Queue::size_type size_type;
// Constructors/Assignment/Destructors
queue_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
// Observers
bool empty() const { return queue->empty(); }
bool full() const { return queue->full(); }
size_type size() const { return queue->size(); }
bool closed() const { return queue->closed(); }
// Modifiers
void close() { queue->close(); }
void pull(value_type& x) { queue->pull(x); };
// enable_if is_nothrow_copy_movable<value_type>
value_type pull() { return queue->pull(); }
queue_op_status try_pull(value_type& x) { return queue->try_pull(x); }
queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull(x); }
queue_op_status wait_pull(value_type& x) { return queue->wait_pull(x); }
};
#if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES
template <class T>
using queue_back = queue_back_view<queue_base<T> > ;
template <class T>
using queue_front = queue_front_view<queue_base<T> > ;
#else
template <class T>
struct queue_back : queue_back_view<queue_base<T> >
{
typedef queue_back_view<queue_base<T> > base_type;
queue_back(queue_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
};
template <class T>
struct queue_front : queue_front_view<queue_base<T> >
{
typedef queue_front_view<queue_base<T> > base_type;
queue_front(queue_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
};
#endif
// template <class Queue>
// queue_back_view<Queue> back(Queue & q) { return queue_back_view<Queue>(q); }
// template <class Queue>
// queue_front_view<Queue> front(Queue & q) { return queue_front_view<Queue>(q); }
//#if 0
// template <class T>
// queue_back<T> back(queue_base<T> & q) { return queue_back<T>(q); }
// template <class T>
// queue_front<T> front(queue_base<T> & q) { return queue_front<T>(q); }
//#else
// template <class T>
// typename queue_back<T>::type back(queue_base<T> & q) { return typename queue_back<T>::type(q); }
// template <class T>
// typename queue_front<T>::type front(queue_base<T> & q) { return typename queue_front<T>::type(q); }
//#endif
}
using concurrent::queue_back_view;
using concurrent::queue_front_view;
using concurrent::queue_back;
using concurrent::queue_front;
//using concurrent::back;
//using concurrent::front;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,727 @@
#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_BOUNDED_QUEUE_HPP
#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_BOUNDED_QUEUE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2013-2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/throw_exception.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#endif
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
template <typename ValueType>
class sync_bounded_queue
{
public:
typedef ValueType value_type;
typedef std::size_t size_type;
// Constructors/Assignment/Destructors
BOOST_THREAD_NO_COPYABLE(sync_bounded_queue)
explicit sync_bounded_queue(size_type max_elems);
template <typename Range>
sync_bounded_queue(size_type max_elems, Range range);
~sync_bounded_queue();
// Observers
inline bool empty() const;
inline bool full() const;
inline size_type capacity() const;
inline size_type size() const;
inline bool closed() const;
// Modifiers
inline void close();
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
inline void push(const value_type& x);
inline void push(BOOST_THREAD_RV_REF(value_type) x);
inline bool try_push(const value_type& x);
inline bool try_push(BOOST_THREAD_RV_REF(value_type) x);
inline bool try_push(no_block_tag, const value_type& x);
inline bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
#endif
inline void push_back(const value_type& x);
inline void push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status try_push_back(const value_type& x);
inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status nonblocking_push_back(const value_type& x);
inline queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status wait_push_back(const value_type& x);
inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x);
// Observers/Modifiers
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
inline void pull(value_type&);
// enable_if is_nothrow_copy_movable<value_type>
inline value_type pull();
inline shared_ptr<ValueType> ptr_pull();
inline bool try_pull(value_type&);
inline bool try_pull(no_block_tag,value_type&);
inline shared_ptr<ValueType> try_pull();
#endif
inline void pull_front(value_type&);
// enable_if is_nothrow_copy_movable<value_type>
inline value_type pull_front();
inline queue_op_status try_pull_front(value_type&);
inline queue_op_status nonblocking_pull_front(value_type&);
inline queue_op_status wait_pull_front(ValueType& elem);
private:
mutable mutex mtx_;
condition_variable not_empty_;
condition_variable not_full_;
size_type waiting_full_;
size_type waiting_empty_;
value_type* data_;
size_type in_;
size_type out_;
size_type capacity_;
bool closed_;
inline size_type inc(size_type idx) const BOOST_NOEXCEPT
{
return (idx + 1) % capacity_;
}
inline bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
{
return in_ == out_;
}
inline bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return in_ == out_;
}
inline bool full(unique_lock<mutex>& ) const BOOST_NOEXCEPT
{
return (inc(in_) == out_);
}
inline bool full(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return (inc(in_) == out_);
}
inline size_type capacity(lock_guard<mutex>& ) const BOOST_NOEXCEPT
{
return capacity_-1;
}
inline size_type size(lock_guard<mutex>& lk) const BOOST_NOEXCEPT
{
if (full(lk)) return capacity(lk);
return ((in_+capacity(lk)-out_) % capacity(lk));
}
inline void throw_if_closed(unique_lock<mutex>&);
inline bool closed(unique_lock<mutex>&) const;
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
inline bool try_pull(value_type& x, unique_lock<mutex>& lk);
inline shared_ptr<value_type> try_pull(unique_lock<mutex>& lk);
inline bool try_push(const value_type& x, unique_lock<mutex>& lk);
inline bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
#endif
inline queue_op_status try_pull_front(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push_back(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline queue_op_status wait_pull_front(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_push_back(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline void wait_until_not_empty(unique_lock<mutex>& lk);
inline void wait_until_not_empty(unique_lock<mutex>& lk, bool&);
inline size_type wait_until_not_full(unique_lock<mutex>& lk);
inline size_type wait_until_not_full(unique_lock<mutex>& lk, bool&);
inline void notify_not_empty_if_needed(unique_lock<mutex>& lk)
{
if (waiting_empty_ > 0)
{
--waiting_empty_;
lk.unlock();
not_empty_.notify_one();
}
}
inline void notify_not_full_if_needed(unique_lock<mutex>& lk)
{
if (waiting_full_ > 0)
{
--waiting_full_;
lk.unlock();
not_full_.notify_one();
}
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
inline void pull(value_type& elem, unique_lock<mutex>& lk)
{
elem = boost::move(data_[out_]);
out_ = inc(out_);
notify_not_full_if_needed(lk);
}
inline value_type pull(unique_lock<mutex>& lk)
{
value_type elem = boost::move(data_[out_]);
out_ = inc(out_);
notify_not_full_if_needed(lk);
return boost::move(elem);
}
inline boost::shared_ptr<value_type> ptr_pull(unique_lock<mutex>& lk)
{
shared_ptr<value_type> res = make_shared<value_type>(boost::move(data_[out_]));
out_ = inc(out_);
notify_not_full_if_needed(lk);
return res;
}
#endif
inline void pull_front(value_type& elem, unique_lock<mutex>& lk)
{
elem = boost::move(data_[out_]);
out_ = inc(out_);
notify_not_full_if_needed(lk);
}
inline value_type pull_front(unique_lock<mutex>& lk)
{
value_type elem = boost::move(data_[out_]);
out_ = inc(out_);
notify_not_full_if_needed(lk);
return boost::move(elem);
}
inline void set_in(size_type in, unique_lock<mutex>& lk)
{
in_ = in;
notify_not_empty_if_needed(lk);
}
inline void push_at(const value_type& elem, size_type in_p_1, unique_lock<mutex>& lk)
{
data_[in_] = elem;
set_in(in_p_1, lk);
}
inline void push_at(BOOST_THREAD_RV_REF(value_type) elem, size_type in_p_1, unique_lock<mutex>& lk)
{
data_[in_] = boost::move(elem);
set_in(in_p_1, lk);
}
};
template <typename ValueType>
sync_bounded_queue<ValueType>::sync_bounded_queue(typename sync_bounded_queue<ValueType>::size_type max_elems) :
waiting_full_(0), waiting_empty_(0), data_(new value_type[max_elems + 1]), in_(0), out_(0), capacity_(max_elems + 1),
closed_(false)
{
BOOST_ASSERT_MSG(max_elems >= 1, "number of elements must be > 1");
}
// template <typename ValueType>
// template <typename Range>
// sync_bounded_queue<ValueType>::sync_bounded_queue(size_type max_elems, Range range) :
// waiting_full_(0), waiting_empty_(0), data_(new value_type[max_elems + 1]), in_(0), out_(0), capacity_(max_elems + 1),
// closed_(false)
// {
// BOOST_ASSERT_MSG(max_elems >= 1, "number of elements must be > 1");
// BOOST_ASSERT_MSG(max_elems == size(range), "number of elements must match range's size");
// try
// {
// typedef typename Range::iterator iterator_t;
// iterator_t first = boost::begin(range);
// iterator_t end = boost::end(range);
// size_type in = 0;
// for (iterator_t cur = first; cur != end; ++cur, ++in)
// {
// data_[in] = *cur;
// }
// set_in(in);
// }
// catch (...)
// {
// delete[] data_;
// }
// }
template <typename ValueType>
sync_bounded_queue<ValueType>::~sync_bounded_queue()
{
delete[] data_;
}
template <typename ValueType>
void sync_bounded_queue<ValueType>::close()
{
{
lock_guard<mutex> lk(mtx_);
closed_ = true;
}
not_empty_.notify_all();
not_full_.notify_all();
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::closed() const
{
lock_guard<mutex> lk(mtx_);
return closed_;
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::closed(unique_lock<mutex>& ) const
{
return closed_;
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::empty() const
{
lock_guard<mutex> lk(mtx_);
return empty(lk);
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::full() const
{
lock_guard<mutex> lk(mtx_);
return full(lk);
}
template <typename ValueType>
typename sync_bounded_queue<ValueType>::size_type sync_bounded_queue<ValueType>::capacity() const
{
lock_guard<mutex> lk(mtx_);
return capacity(lk);
}
template <typename ValueType>
typename sync_bounded_queue<ValueType>::size_type sync_bounded_queue<ValueType>::size() const
{
lock_guard<mutex> lk(mtx_);
return size(lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_pull(ValueType& elem, unique_lock<mutex>& lk)
{
if (empty(lk))
{
throw_if_closed(lk);
return false;
}
pull(elem, lk);
return true;
}
template <typename ValueType>
shared_ptr<ValueType> sync_bounded_queue<ValueType>::try_pull(unique_lock<mutex>& lk)
{
if (empty(lk))
{
throw_if_closed(lk);
return shared_ptr<ValueType>();
}
return ptr_pull(lk);
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_pull(ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return try_pull(elem, lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_pull_front(ValueType& elem, unique_lock<mutex>& lk)
{
if (empty(lk))
{
if (closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
pull_front(elem, lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return try_pull_front(elem, lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_pull(no_block_tag,ValueType& elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock())
{
return false;
}
return try_pull(elem, lk);
}
template <typename ValueType>
boost::shared_ptr<ValueType> sync_bounded_queue<ValueType>::try_pull()
{
unique_lock<mutex> lk(mtx_);
return try_pull(lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::nonblocking_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_pull_front(elem, lk);
}
template <typename ValueType>
void sync_bounded_queue<ValueType>::throw_if_closed(unique_lock<mutex>&)
{
if (closed_)
{
BOOST_THROW_EXCEPTION( sync_queue_is_closed() );
}
}
template <typename ValueType>
void sync_bounded_queue<ValueType>::wait_until_not_empty(unique_lock<mutex>& lk)
{
for (;;)
{
if (out_ != in_) break;
throw_if_closed(lk);
++waiting_empty_;
not_empty_.wait(lk);
}
}
template <typename ValueType>
void sync_bounded_queue<ValueType>::wait_until_not_empty(unique_lock<mutex>& lk, bool & closed)
{
for (;;)
{
if (out_ != in_) break;
if (closed_) {closed=true; return;}
++waiting_empty_;
not_empty_.wait(lk);
}
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
void sync_bounded_queue<ValueType>::pull(ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
wait_until_not_empty(lk);
pull(elem, lk);
}
// template <typename ValueType>
// void sync_bounded_queue<ValueType>::pull(ValueType& elem, bool & closed)
// {
// unique_lock<mutex> lk(mtx_);
// wait_until_not_empty(lk, closed);
// if (closed) {return;}
// pull(elem, lk);
// }
// enable if ValueType is nothrow movable
template <typename ValueType>
ValueType sync_bounded_queue<ValueType>::pull()
{
unique_lock<mutex> lk(mtx_);
wait_until_not_empty(lk);
return pull(lk);
}
template <typename ValueType>
boost::shared_ptr<ValueType> sync_bounded_queue<ValueType>::ptr_pull()
{
unique_lock<mutex> lk(mtx_);
wait_until_not_empty(lk);
return ptr_pull(lk);
}
#endif
template <typename ValueType>
void sync_bounded_queue<ValueType>::pull_front(ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
wait_until_not_empty(lk);
pull_front(elem, lk);
}
// enable if ValueType is nothrow movable
template <typename ValueType>
ValueType sync_bounded_queue<ValueType>::pull_front()
{
unique_lock<mutex> lk(mtx_);
wait_until_not_empty(lk);
return pull_front(lk);
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_pull_front(ValueType& elem, unique_lock<mutex>& lk)
{
if (empty(lk) && closed(lk)) {return queue_op_status::closed;}
bool is_closed = false;
wait_until_not_empty(lk, is_closed);
if (is_closed) {return queue_op_status::closed;}
pull_front(elem, lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return wait_pull_front(elem, lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(const ValueType& elem, unique_lock<mutex>& lk)
{
throw_if_closed(lk);
size_type in_p_1 = inc(in_);
if (in_p_1 == out_) // full()
{
return false;
}
push_at(elem, in_p_1, lk);
return true;
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return try_push(elem, lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_push_back(const ValueType& elem, unique_lock<mutex>& lk)
{
if (closed(lk)) return queue_op_status::closed;
size_type in_p_1 = inc(in_);
if (in_p_1 == out_) // full()
{
return queue_op_status::full;
}
push_at(elem, in_p_1, lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return try_push_back(elem, lk);
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_push_back(const ValueType& elem, unique_lock<mutex>& lk)
{
if (closed(lk)) return queue_op_status::closed;
push_at(elem, wait_until_not_full(lk), lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
return wait_push_back(elem, lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(no_block_tag, const ValueType& elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock()) return false;
return try_push(elem, lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::nonblocking_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock()) return queue_op_status::busy;
return try_push_back(elem, lk);
}
template <typename ValueType>
typename sync_bounded_queue<ValueType>::size_type sync_bounded_queue<ValueType>::wait_until_not_full(unique_lock<mutex>& lk)
{
for (;;)
{
throw_if_closed(lk);
size_type in_p_1 = inc(in_);
if (in_p_1 != out_) // ! full()
{
return in_p_1;
}
++waiting_full_;
not_full_.wait(lk);
}
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
void sync_bounded_queue<ValueType>::push(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
push_at(elem, wait_until_not_full(lk), lk);
}
#endif
template <typename ValueType>
void sync_bounded_queue<ValueType>::push_back(const ValueType& elem)
{
unique_lock<mutex> lk(mtx_);
push_at(elem, wait_until_not_full(lk), lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
throw_if_closed(lk);
size_type in_p_1 = inc(in_);
if (in_p_1 == out_) // full()
{
return false;
}
push_at(boost::move(elem), in_p_1, lk);
return true;
}
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_);
return try_push(boost::move(elem), lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (closed(lk)) return queue_op_status::closed;
size_type in_p_1 = inc(in_);
if (in_p_1 == out_) // full()
{
return queue_op_status::full;
}
push_at(boost::move(elem), in_p_1, lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_);
return try_push_back(boost::move(elem), lk);
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (closed(lk)) return queue_op_status::closed;
push_at(boost::move(elem), wait_until_not_full(lk), lk);
return queue_op_status::success;
}
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_);
return try_push_back(boost::move(elem), lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
bool sync_bounded_queue<ValueType>::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock())
{
return false;
}
return try_push(boost::move(elem), lk);
}
#endif
template <typename ValueType>
queue_op_status sync_bounded_queue<ValueType>::nonblocking_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_push_back(boost::move(elem), lk);
}
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
template <typename ValueType>
void sync_bounded_queue<ValueType>::push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_);
push_at(boost::move(elem), wait_until_not_full(lk), lk);
}
#endif
template <typename ValueType>
void sync_bounded_queue<ValueType>::push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(mtx_);
push_at(boost::move(elem), wait_until_not_full(lk), lk);
}
template <typename ValueType>
sync_bounded_queue<ValueType>& operator<<(sync_bounded_queue<ValueType>& sbq, BOOST_THREAD_RV_REF(ValueType) elem)
{
sbq.push_back(boost::move(elem));
return sbq;
}
template <typename ValueType>
sync_bounded_queue<ValueType>& operator<<(sync_bounded_queue<ValueType>& sbq, ValueType const&elem)
{
sbq.push_back(elem);
return sbq;
}
template <typename ValueType>
sync_bounded_queue<ValueType>& operator>>(sync_bounded_queue<ValueType>& sbq, ValueType &elem)
{
sbq.pull_front(elem);
return sbq;
}
}
using concurrent::sync_bounded_queue;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,327 @@
#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_DEQUE_HPP
#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_DEQUE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2013-2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/thread/detail/config.hpp>
#include <boost/thread/concurrent_queues/detail/sync_queue_base.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/csbl/devector.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/throw_exception.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
template <class ValueType, class Container = csbl::devector<ValueType> >
class sync_deque
: public detail::sync_queue_base<ValueType, Container >
{
typedef detail::sync_queue_base<ValueType, Container > super;
public:
typedef ValueType value_type;
//typedef typename super::value_type value_type; // fixme
typedef typename super::underlying_queue_type underlying_queue_type;
typedef typename super::size_type size_type;
typedef typename super::op_status op_status;
// Constructors/Assignment/Destructors
BOOST_THREAD_NO_COPYABLE(sync_deque)
inline sync_deque();
//template <typename Range>
//inline explicit sync_deque(Range range);
inline ~sync_deque();
// Modifiers
inline void push_back(const value_type& x);
inline queue_op_status try_push_back(const value_type& x);
inline queue_op_status nonblocking_push_back(const value_type& x);
inline queue_op_status wait_push_back(const value_type& x);
inline void push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x);
// Observers/Modifiers
inline void pull_front(value_type&);
// enable_if is_nothrow_copy_movable<value_type>
inline value_type pull_front();
inline queue_op_status try_pull_front(value_type&);
inline queue_op_status nonblocking_pull_front(value_type&);
inline queue_op_status wait_pull_front(ValueType& elem);
private:
inline queue_op_status try_pull_front(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_pull_front(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push_back(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_push_back(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline void pull_front(value_type& elem, unique_lock<mutex>& )
{
elem = boost::move(super::data_.front());
super::data_.pop_front();
}
inline value_type pull_front(unique_lock<mutex>& )
{
value_type e = boost::move(super::data_.front());
super::data_.pop_front();
return boost::move(e);
}
inline void push_back(const value_type& elem, unique_lock<mutex>& lk)
{
super::data_.push_back(elem);
super::notify_not_empty_if_needed(lk);
}
inline void push_back(BOOST_THREAD_RV_REF(value_type) elem, unique_lock<mutex>& lk)
{
super::data_.push_back(boost::move(elem));
super::notify_not_empty_if_needed(lk);
}
};
template <class ValueType, class Container>
sync_deque<ValueType, Container>::sync_deque() :
super()
{
}
// template <class ValueType, class Container>
// template <class Range>
// explicit sync_deque<ValueType, Container>::sync_deque(Range range) :
// data_(), closed_(false)
// {
// try
// {
// typedef typename Range::iterator iterator_t;
// iterator_t first = boost::begin(range);
// iterator_t end = boost::end(range);
// for (iterator_t cur = first; cur != end; ++cur)
// {
// data_.push(boost::move(*cur));;
// }
// notify_not_empty_if_needed(lk);
// }
// catch (...)
// {
// delete[] data_;
// }
// }
template <class ValueType, class Container>
sync_deque<ValueType, Container>::~sync_deque()
{
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_pull_front(ValueType& elem, unique_lock<mutex>& lk)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
pull_front(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_pull_front(ValueType& elem, unique_lock<mutex>& lk)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
}
bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
if (has_been_closed) return queue_op_status::closed;
pull_front(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_pull_front(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_pull_front(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::nonblocking_pull_front(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_pull_front(elem, lk);
}
template <class ValueType, class Container>
void sync_deque<ValueType, Container>::pull_front(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
pull_front(elem, lk);
}
// enable if ValueType is nothrow movable
template <class ValueType, class Container>
ValueType sync_deque<ValueType, Container>::pull_front()
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
return pull_front(lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_push_back(const ValueType& elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push_back(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_push_back(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_push_back(const ValueType& elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push_back(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_push_back(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::nonblocking_push_back(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock()) return queue_op_status::busy;
return try_push_back(elem, lk);
}
template <class ValueType, class Container>
void sync_deque<ValueType, Container>::push_back(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::throw_if_closed(lk);
push_back(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push_back(boost::move(elem), lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_push_back(boost::move(elem), lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push_back(boost::move(elem), lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_push_back(boost::move(elem), lk);
}
template <class ValueType, class Container>
queue_op_status sync_deque<ValueType, Container>::nonblocking_push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_push_back(boost::move(elem), lk);
}
template <class ValueType, class Container>
void sync_deque<ValueType, Container>::push_back(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
super::throw_if_closed(lk);
push_back(boost::move(elem), lk);
}
template <class ValueType, class Container>
sync_deque<ValueType, Container>& operator<<(sync_deque<ValueType, Container>& sbq, BOOST_THREAD_RV_REF(ValueType) elem)
{
sbq.push_back(boost::move(elem));
return sbq;
}
template <class ValueType, class Container>
sync_deque<ValueType, Container>& operator<<(sync_deque<ValueType, Container>& sbq, ValueType const&elem)
{
sbq.push_back(elem);
return sbq;
}
template <class ValueType, class Container>
sync_deque<ValueType, Container>& operator>>(sync_deque<ValueType, Container>& sbq, ValueType &elem)
{
sbq.pull_front(elem);
return sbq;
}
}
using concurrent::sync_deque;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,369 @@
// Copyright (C) 2014 Ian Forbed
// Copyright (C) 2014 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)
//
#ifndef BOOST_THREAD_SYNC_PRIORITY_QUEUE
#define BOOST_THREAD_SYNC_PRIORITY_QUEUE
#include <boost/thread/detail/config.hpp>
#include <boost/thread/concurrent_queues/detail/sync_queue_base.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/csbl/vector.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/atomic.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <exception>
#include <queue>
#include <utility>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace detail {
template <
class Type,
class Container = csbl::vector<Type>,
class Compare = std::less<Type>
>
class priority_queue
{
private:
Container _elements;
Compare _compare;
public:
typedef Type value_type;
typedef typename Container::size_type size_type;
explicit priority_queue(const Compare& compare = Compare())
: _elements(), _compare(compare)
{ }
size_type size() const
{
return _elements.size();
}
bool empty() const
{
return _elements.empty();
}
void push(Type const& element)
{
_elements.push_back(element);
std::push_heap(_elements.begin(), _elements.end(), _compare);
}
void push(BOOST_RV_REF(Type) element)
{
_elements.push_back(boost::move(element));
std::push_heap(_elements.begin(), _elements.end(), _compare);
}
void pop()
{
std::pop_heap(_elements.begin(), _elements.end(), _compare);
_elements.pop_back();
}
Type pull()
{
Type result = boost::move(_elements.front());
pop();
return boost::move(result);
}
Type const& top()
{
return _elements.front();
}
};
}
namespace concurrent
{
template <class ValueType,
class Container = csbl::vector<ValueType>,
class Compare = std::less<typename Container::value_type> >
class sync_priority_queue
: public detail::sync_queue_base<ValueType, boost::detail::priority_queue<ValueType,Container,Compare> >
{
typedef detail::sync_queue_base<ValueType, boost::detail::priority_queue<ValueType,Container,Compare> > super;
public:
typedef ValueType value_type;
//typedef typename super::value_type value_type; // fixme
typedef typename super::underlying_queue_type underlying_queue_type;
typedef typename super::size_type size_type;
typedef typename super::op_status op_status;
typedef chrono::steady_clock clock;
protected:
public:
sync_priority_queue() {}
~sync_priority_queue()
{
if(!super::closed())
{
super::close();
}
}
void push(const ValueType& elem);
void push(BOOST_THREAD_RV_REF(ValueType) elem);
queue_op_status try_push(const ValueType& elem);
queue_op_status try_push(BOOST_THREAD_RV_REF(ValueType) elem);
ValueType pull();
void pull(ValueType&);
queue_op_status pull_until(const clock::time_point&, ValueType&);
queue_op_status pull_for(const clock::duration&, ValueType&);
queue_op_status try_pull(ValueType& elem);
queue_op_status wait_pull(ValueType& elem);
queue_op_status nonblocking_pull(ValueType&);
private:
void push(unique_lock<mutex>&, const ValueType& elem);
void push(lock_guard<mutex>&, const ValueType& elem);
void push(unique_lock<mutex>&, BOOST_THREAD_RV_REF(ValueType) elem);
void push(lock_guard<mutex>&, BOOST_THREAD_RV_REF(ValueType) elem);
queue_op_status try_push(unique_lock<mutex>&, const ValueType& elem);
queue_op_status try_push(unique_lock<mutex>&, BOOST_THREAD_RV_REF(ValueType) elem);
ValueType pull(unique_lock<mutex>&);
ValueType pull(lock_guard<mutex>&);
void pull(unique_lock<mutex>&, ValueType&);
void pull(lock_guard<mutex>&, ValueType&);
queue_op_status try_pull(lock_guard<mutex>& lk, ValueType& elem);
queue_op_status try_pull(unique_lock<mutex>& lk, ValueType& elem);
queue_op_status wait_pull(unique_lock<mutex>& lk, ValueType& elem);
queue_op_status nonblocking_pull(unique_lock<mutex>& lk, ValueType&);
sync_priority_queue(const sync_priority_queue&);
sync_priority_queue& operator= (const sync_priority_queue&);
sync_priority_queue(BOOST_THREAD_RV_REF(sync_priority_queue));
sync_priority_queue& operator= (BOOST_THREAD_RV_REF(sync_priority_queue));
}; //end class
//////////////////////
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(unique_lock<mutex>& lk, const T& elem)
{
super::throw_if_closed(lk);
super::data_.push(elem);
super::notify_not_empty_if_needed(lk);
}
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(lock_guard<mutex>& lk, const T& elem)
{
super::throw_if_closed(lk);
super::data_.push(elem);
super::notify_not_empty_if_needed(lk);
}
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(const T& elem)
{
lock_guard<mutex> lk(super::mtx_);
push(lk, elem);
}
//////////////////////
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(unique_lock<mutex>& lk, BOOST_THREAD_RV_REF(T) elem)
{
super::throw_if_closed(lk);
super::data_.push(boost::move(elem));
super::notify_not_empty_if_needed(lk);
}
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(lock_guard<mutex>& lk, BOOST_THREAD_RV_REF(T) elem)
{
super::throw_if_closed(lk);
super::data_.push(boost::move(elem));
super::notify_not_empty_if_needed(lk);
}
template <class T, class Container,class Cmp>
void sync_priority_queue<T,Container,Cmp>::push(BOOST_THREAD_RV_REF(T) elem)
{
lock_guard<mutex> lk(super::mtx_);
push(lk, boost::move(elem));
}
//////////////////////
template <class T, class Container,class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::try_push(const T& elem)
{
lock_guard<mutex> lk(super::mtx_);
if (super::closed(lk)) return queue_op_status::closed;
push(lk, elem);
return queue_op_status::success;
}
//////////////////////
template <class T, class Container,class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::try_push(BOOST_THREAD_RV_REF(T) elem)
{
lock_guard<mutex> lk(super::mtx_);
if (super::closed(lk)) return queue_op_status::closed;
push(lk, boost::move(elem));
return queue_op_status::success;
}
//////////////////////
template <class T,class Container, class Cmp>
T sync_priority_queue<T,Container,Cmp>::pull(unique_lock<mutex>&)
{
return super::data_.pull();
}
template <class T,class Container, class Cmp>
T sync_priority_queue<T,Container,Cmp>::pull(lock_guard<mutex>&)
{
return super::data_.pull();
}
template <class T,class Container, class Cmp>
T sync_priority_queue<T,Container,Cmp>::pull()
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
return pull(lk);
}
//////////////////////
template <class T,class Container, class Cmp>
void sync_priority_queue<T,Container,Cmp>::pull(unique_lock<mutex>&, T& elem)
{
elem = super::data_.pull();
}
template <class T,class Container, class Cmp>
void sync_priority_queue<T,Container,Cmp>::pull(lock_guard<mutex>&, T& elem)
{
elem = super::data_.pull();
}
template <class T,class Container, class Cmp>
void sync_priority_queue<T,Container,Cmp>::pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
pull(lk, elem);
}
//////////////////////
template <class T, class Cont,class Cmp>
queue_op_status
sync_priority_queue<T,Cont,Cmp>::pull_until(const clock::time_point& tp, T& elem)
{
unique_lock<mutex> lk(super::mtx_);
if (queue_op_status::timeout == super::wait_until_not_empty_until(lk, tp))
return queue_op_status::timeout;
pull(lk, elem);
return queue_op_status::success;
}
//////////////////////
template <class T, class Cont,class Cmp>
queue_op_status
sync_priority_queue<T,Cont,Cmp>::pull_for(const clock::duration& dura, T& elem)
{
return pull_until(clock::now() + dura, elem);
}
//////////////////////
template <class T, class Container,class Cmp>
queue_op_status
sync_priority_queue<T,Container,Cmp>::try_pull(unique_lock<mutex>& lk, T& elem)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
pull(lk, elem);
return queue_op_status::success;
}
template <class T, class Container,class Cmp>
queue_op_status
sync_priority_queue<T,Container,Cmp>::try_pull(lock_guard<mutex>& lk, T& elem)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
pull(lk, elem);
return queue_op_status::success;
}
template <class T, class Container,class Cmp>
queue_op_status
sync_priority_queue<T,Container,Cmp>::try_pull(T& elem)
{
lock_guard<mutex> lk(super::mtx_);
return try_pull(lk, elem);
}
//////////////////////
template <class T,class Container, class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::wait_pull(unique_lock<mutex>& lk, T& elem)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
}
bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
if (has_been_closed) return queue_op_status::closed;
pull(lk, elem);
return queue_op_status::success;
}
template <class T,class Container, class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::wait_pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_pull(lk, elem);
}
//////////////////////
template <class T,class Container, class Cmp>
queue_op_status sync_priority_queue<T,Container,Cmp>::nonblocking_pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock()) return queue_op_status::busy;
return try_pull(lk, elem);
}
} //end concurrent namespace
using concurrent::sync_priority_queue;
} //end boost namespace
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,335 @@
#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_QUEUE_HPP
#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_QUEUE_HPP
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2013-2014. 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)
//
// See http://www.boost.org/libs/thread for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <boost/thread/detail/config.hpp>
#include <boost/thread/concurrent_queues/detail/sync_queue_base.hpp>
#include <boost/thread/concurrent_queues/queue_op_status.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/csbl/devector.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/throw_exception.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
template <class ValueType, class Container = csbl::devector<ValueType> >
class sync_queue
: public detail::sync_queue_base<ValueType, Container >
{
typedef detail::sync_queue_base<ValueType, Container > super;
public:
typedef ValueType value_type;
//typedef typename super::value_type value_type; // fixme
typedef typename super::underlying_queue_type underlying_queue_type;
typedef typename super::size_type size_type;
typedef typename super::op_status op_status;
// Constructors/Assignment/Destructors
BOOST_THREAD_NO_COPYABLE(sync_queue)
inline sync_queue();
//template <class Range>
//inline explicit sync_queue(Range range);
inline ~sync_queue();
// Modifiers
inline void push(const value_type& x);
inline queue_op_status try_push(const value_type& x);
inline queue_op_status nonblocking_push(const value_type& x);
inline queue_op_status wait_push(const value_type& x);
inline void push(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x);
inline queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x);
// Observers/Modifiers
inline void pull(value_type&);
// enable_if is_nothrow_copy_movable<value_type>
inline value_type pull();
inline queue_op_status try_pull(value_type&);
inline queue_op_status nonblocking_pull(value_type&);
inline queue_op_status wait_pull(ValueType& elem);
private:
inline queue_op_status try_pull(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_pull(value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status wait_push(const value_type& x, unique_lock<mutex>& lk);
inline queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
inline void pull(value_type& elem, unique_lock<mutex>& )
{
elem = boost::move(super::data_.front());
super::data_.pop_front();
}
inline value_type pull(unique_lock<mutex>& )
{
value_type e = boost::move(super::data_.front());
super::data_.pop_front();
return boost::move(e);
}
inline void push(const value_type& elem, unique_lock<mutex>& lk)
{
super::data_.push_back(elem);
super::notify_not_empty_if_needed(lk);
}
inline void push(BOOST_THREAD_RV_REF(value_type) elem, unique_lock<mutex>& lk)
{
super::data_.push_back(boost::move(elem));
super::notify_not_empty_if_needed(lk);
}
};
template <class ValueType, class Container>
sync_queue<ValueType, Container>::sync_queue() :
super()
{
}
// template <class ValueType, class Container>
// template <class Range>
// explicit sync_queue<ValueType, Container>::sync_queue(Range range) :
// data_(), closed_(false)
// {
// try
// {
// typedef typename Range::iterator iterator_t;
// iterator_t first = boost::begin(range);
// iterator_t end = boost::end(range);
// for (iterator_t cur = first; cur != end; ++cur)
// {
// data_.push(boost::move(*cur));;
// }
// notify_not_empty_if_needed(lk);
// }
// catch (...)
// {
// delete[] data_;
// }
// }
template <class ValueType, class Container>
sync_queue<ValueType, Container>::~sync_queue()
{
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_pull(ValueType& elem, unique_lock<mutex>& lk)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
pull(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_pull(ValueType& elem, unique_lock<mutex>& lk)
{
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
if (super::empty(lk))
{
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
if (super::closed(lk)) return queue_op_status::closed;
}
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
if (has_been_closed) return queue_op_status::closed;
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
pull(elem, lk);
//std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_pull(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_pull(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_pull(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_pull(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::nonblocking_pull(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_pull(elem, lk);
}
template <class ValueType, class Container>
void sync_queue<ValueType, Container>::pull(ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
pull(elem, lk);
}
// enable if ValueType is nothrow movable
template <class ValueType, class Container>
ValueType sync_queue<ValueType, Container>::pull()
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
return pull(lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_push(const ValueType& elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_push(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_push(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_push(const ValueType& elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push(elem, lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_push(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_push(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::nonblocking_push(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock()) return queue_op_status::busy;
return try_push(elem, lk);
}
template <class ValueType, class Container>
void sync_queue<ValueType, Container>::push(const ValueType& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::throw_if_closed(lk);
push(elem, lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push(boost::move(elem), lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::try_push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
return try_push(boost::move(elem), lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock<mutex>& lk)
{
if (super::closed(lk)) return queue_op_status::closed;
push(boost::move(elem), lk);
return queue_op_status::success;
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::wait_push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_push(boost::move(elem), lk);
}
template <class ValueType, class Container>
queue_op_status sync_queue<ValueType, Container>::nonblocking_push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (!lk.owns_lock())
{
return queue_op_status::busy;
}
return try_push(boost::move(elem), lk);
}
template <class ValueType, class Container>
void sync_queue<ValueType, Container>::push(BOOST_THREAD_RV_REF(ValueType) elem)
{
unique_lock<mutex> lk(super::mtx_);
super::throw_if_closed(lk);
push(boost::move(elem), lk);
}
template <class ValueType, class Container>
sync_queue<ValueType, Container>& operator<<(sync_queue<ValueType, Container>& sbq, BOOST_THREAD_RV_REF(ValueType) elem)
{
sbq.push(boost::move(elem));
return sbq;
}
template <class ValueType, class Container>
sync_queue<ValueType, Container>& operator<<(sync_queue<ValueType, Container>& sbq, ValueType const&elem)
{
sbq.push(elem);
return sbq;
}
template <class ValueType, class Container>
sync_queue<ValueType, Container>& operator>>(sync_queue<ValueType, Container>& sbq, ValueType &elem)
{
sbq.pull(elem);
return sbq;
}
}
using concurrent::sync_queue;
}
#include <boost/config/abi_suffix.hpp>
#endif

View File

@@ -0,0 +1,468 @@
// Copyright (C) 2014 Ian Forbed
// Copyright (C) 2014 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)
//
#ifndef BOOST_THREAD_SYNC_TIMED_QUEUE_HPP
#define BOOST_THREAD_SYNC_TIMED_QUEUE_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/thread/concurrent_queues/sync_priority_queue.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
#include <boost/chrono/chrono_io.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace concurrent
{
namespace detail
{
template <class T, class Clock = chrono::steady_clock>
struct scheduled_type
{
typedef T value_type;
typedef Clock clock;
typedef typename clock::time_point time_point;
T data;
time_point time;
BOOST_THREAD_COPYABLE_AND_MOVABLE(scheduled_type)
scheduled_type(T const& pdata, time_point tp) : data(pdata), time(tp) {}
scheduled_type(BOOST_THREAD_RV_REF(T) pdata, time_point tp) : data(boost::move(pdata)), time(tp) {}
scheduled_type(scheduled_type const& other) : data(other.data), time(other.time) {}
scheduled_type& operator=(BOOST_THREAD_COPY_ASSIGN_REF(scheduled_type) other) {
data = other.data;
time = other.time;
return *this;
}
scheduled_type(BOOST_THREAD_RV_REF(scheduled_type) other) : data(boost::move(other.data)), time(other.time) {}
scheduled_type& operator=(BOOST_THREAD_RV_REF(scheduled_type) other) {
data = boost::move(other.data);
time = other.time;
return *this;
}
bool time_not_reached() const
{
return time > clock::now();
}
bool operator <(const scheduled_type<T> other) const
{
return this->time > other.time;
}
}; //end struct
} //end detail namespace
template <class T, class Clock = chrono::steady_clock>
class sync_timed_queue
: private sync_priority_queue<detail::scheduled_type<T, Clock> >
{
typedef detail::scheduled_type<T, Clock> stype;
typedef sync_priority_queue<stype> super;
public:
typedef T value_type;
typedef Clock clock;
typedef typename clock::duration duration;
typedef typename clock::time_point time_point;
typedef typename super::underlying_queue_type underlying_queue_type;
typedef typename super::size_type size_type;
typedef typename super::op_status op_status;
sync_timed_queue() : super() {};
~sync_timed_queue() {}
using super::size;
using super::empty;
using super::full;
using super::close;
using super::closed;
T pull();
void pull(T& elem);
template <class Duration>
queue_op_status pull_until(chrono::time_point<clock,Duration> const& tp, T& elem);
template <class Rep, class Period>
queue_op_status pull_for(chrono::duration<Rep,Period> const& dura, T& elem);
queue_op_status try_pull(T& elem);
queue_op_status wait_pull(T& elem);
queue_op_status nonblocking_pull(T& elem);
template <class Duration>
void push(const T& elem, chrono::time_point<clock,Duration> const& tp);
template <class Rep, class Period>
void push(const T& elem, chrono::duration<Rep,Period> const& dura);
template <class Duration>
void push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point<clock,Duration> const& tp);
template <class Rep, class Period>
void push(BOOST_THREAD_RV_REF(T) elem, chrono::duration<Rep,Period> const& dura);
template <class Duration>
queue_op_status try_push(const T& elem, chrono::time_point<clock,Duration> const& tp);
template <class Rep, class Period>
queue_op_status try_push(const T& elem, chrono::duration<Rep,Period> const& dura);
template <class Duration>
queue_op_status try_push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point<clock,Duration> const& tp);
template <class Rep, class Period>
queue_op_status try_push(BOOST_THREAD_RV_REF(T) elem, chrono::duration<Rep,Period> const& dura);
private:
T pull(unique_lock<mutex>&);
T pull(lock_guard<mutex>&);
void pull(unique_lock<mutex>&, T& elem);
void pull(lock_guard<mutex>&, T& elem);
queue_op_status try_pull(unique_lock<mutex>&, T& elem);
queue_op_status try_pull(lock_guard<mutex>&, T& elem);
queue_op_status wait_pull(unique_lock<mutex>& lk, T& elem);
bool wait_until_not_empty_time_reached_or_closed(unique_lock<mutex>&);
T pull_when_time_reached(unique_lock<mutex>&);
template <class Duration>
queue_op_status pull_when_time_reached_until(unique_lock<mutex>&, chrono::time_point<clock,Duration> const& tp, T& elem);
bool time_not_reached(unique_lock<mutex>&);
bool time_not_reached(lock_guard<mutex>&);
bool empty_or_time_not_reached(unique_lock<mutex>&);
bool empty_or_time_not_reached(lock_guard<mutex>&);
sync_timed_queue(const sync_timed_queue&);
sync_timed_queue& operator=(const sync_timed_queue&);
sync_timed_queue(BOOST_THREAD_RV_REF(sync_timed_queue));
sync_timed_queue& operator=(BOOST_THREAD_RV_REF(sync_timed_queue));
}; //end class
template <class T, class Clock>
template <class Duration>
void sync_timed_queue<T, Clock>::push(const T& elem, chrono::time_point<clock,Duration> const& tp)
{
super::push(stype(elem,tp));
}
template <class T, class Clock>
template <class Rep, class Period>
void sync_timed_queue<T, Clock>::push(const T& elem, chrono::duration<Rep,Period> const& dura)
{
push(elem, clock::now() + dura);
}
template <class T, class Clock>
template <class Duration>
void sync_timed_queue<T, Clock>::push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point<clock,Duration> const& tp)
{
super::push(stype(boost::move(elem),tp));
}
template <class T, class Clock>
template <class Rep, class Period>
void sync_timed_queue<T, Clock>::push(BOOST_THREAD_RV_REF(T) elem, chrono::duration<Rep,Period> const& dura)
{
push(boost::move(elem), clock::now() + dura);
}
template <class T, class Clock>
template <class Duration>
queue_op_status sync_timed_queue<T, Clock>::try_push(const T& elem, chrono::time_point<clock,Duration> const& tp)
{
return super::try_push(stype(elem,tp));
}
template <class T, class Clock>
template <class Rep, class Period>
queue_op_status sync_timed_queue<T, Clock>::try_push(const T& elem, chrono::duration<Rep,Period> const& dura)
{
return try_push(elem,clock::now() + dura);
}
template <class T, class Clock>
template <class Duration>
queue_op_status sync_timed_queue<T, Clock>::try_push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point<clock,Duration> const& tp)
{
return super::try_push(stype(boost::move(elem), tp));
}
template <class T, class Clock>
template <class Rep, class Period>
queue_op_status sync_timed_queue<T, Clock>::try_push(BOOST_THREAD_RV_REF(T) elem, chrono::duration<Rep,Period> const& dura)
{
return try_push(boost::move(elem), clock::now() + dura);
}
///////////////////////////
template <class T, class Clock>
bool sync_timed_queue<T, Clock>::time_not_reached(unique_lock<mutex>&)
{
return super::data_.top().time_not_reached();
}
template <class T, class Clock>
bool sync_timed_queue<T, Clock>::time_not_reached(lock_guard<mutex>&)
{
return super::data_.top().time_not_reached();
}
///////////////////////////
template <class T, class Clock>
bool sync_timed_queue<T, Clock>::wait_until_not_empty_time_reached_or_closed(unique_lock<mutex>& lk)
{
for (;;)
{
if (super::closed(lk)) return true;
while (! super::empty(lk)) {
if (! time_not_reached(lk)) return false;
time_point tp = super::data_.top().time;
super::not_empty_.wait_until(lk, tp);
if (super::closed(lk)) return true;
}
if (super::closed(lk)) return true;
super::not_empty_.wait(lk);
}
//return false;
}
///////////////////////////
template <class T, class Clock>
T sync_timed_queue<T, Clock>::pull_when_time_reached(unique_lock<mutex>& lk)
{
while (time_not_reached(lk))
{
super::throw_if_closed(lk);
time_point tp = super::data_.top().time;
super::not_empty_.wait_until(lk,tp);
super::wait_until_not_empty(lk);
}
return pull(lk);
}
template <class T, class Clock>
template <class Duration>
queue_op_status
sync_timed_queue<T, Clock>::pull_when_time_reached_until(unique_lock<mutex>& lk, chrono::time_point<clock,Duration> const& tp, T& elem)
{
chrono::time_point<clock,Duration> tpmin = (tp < super::data_.top().time) ? tp : super::data_.top().time;
while (time_not_reached(lk))
{
super::throw_if_closed(lk);
if (cv_status::timeout == super::not_empty_.wait_until(lk, tpmin)) {
if (time_not_reached(lk)) return queue_op_status::not_ready;
return queue_op_status::timeout;
}
}
pull(lk, elem);
return queue_op_status::success;
}
///////////////////////////
template <class T, class Clock>
bool sync_timed_queue<T, Clock>::empty_or_time_not_reached(unique_lock<mutex>& lk)
{
if ( super::empty(lk) ) return true;
if ( time_not_reached(lk) ) return true;
return false;
}
template <class T, class Clock>
bool sync_timed_queue<T, Clock>::empty_or_time_not_reached(lock_guard<mutex>& lk)
{
if ( super::empty(lk) ) return true;
if ( time_not_reached(lk) ) return true;
return false;
}
///////////////////////////
template <class T, class Clock>
T sync_timed_queue<T, Clock>::pull(unique_lock<mutex>&)
{
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
return boost::move(super::data_.pull().data);
#else
return super::data_.pull().data;
#endif
}
template <class T, class Clock>
T sync_timed_queue<T, Clock>::pull(lock_guard<mutex>&)
{
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
return boost::move(super::data_.pull().data);
#else
return super::data_.pull().data;
#endif
}
template <class T, class Clock>
T sync_timed_queue<T, Clock>::pull()
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
return pull_when_time_reached(lk);
}
///////////////////////////
template <class T, class Clock>
void sync_timed_queue<T, Clock>::pull(unique_lock<mutex>&, T& elem)
{
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
elem = boost::move(super::data_.pull().data);
#else
elem = super::data_.pull().data;
#endif
}
template <class T, class Clock>
void sync_timed_queue<T, Clock>::pull(lock_guard<mutex>&, T& elem)
{
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
elem = boost::move(super::data_.pull().data);
#else
elem = super::data_.pull().data;
#endif
}
template <class T, class Clock>
void sync_timed_queue<T, Clock>::pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_);
super::wait_until_not_empty(lk);
elem = pull_when_time_reached(lk);
}
//////////////////////
template <class T, class Clock>
template <class Duration>
queue_op_status
sync_timed_queue<T, Clock>::pull_until(chrono::time_point<clock,Duration> const& tp, T& elem)
{
unique_lock<mutex> lk(super::mtx_);
if (queue_op_status::timeout == super::wait_until_not_empty_until(lk, tp))
return queue_op_status::timeout;
return pull_when_time_reached_until(lk, tp, elem);
}
//////////////////////
template <class T, class Clock>
template <class Rep, class Period>
queue_op_status
sync_timed_queue<T, Clock>::pull_for(chrono::duration<Rep,Period> const& dura, T& elem)
{
return pull_until(clock::now() + dura, elem);
}
///////////////////////////
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::try_pull(unique_lock<mutex>& lk, T& elem)
{
if ( super::empty(lk) )
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
if ( time_not_reached(lk) )
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::not_ready;
}
pull(lk, elem);
return queue_op_status::success;
}
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::try_pull(lock_guard<mutex>& lk, T& elem)
{
if ( super::empty(lk) )
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::empty;
}
if ( time_not_reached(lk) )
{
if (super::closed(lk)) return queue_op_status::closed;
return queue_op_status::not_ready;
}
pull(lk, elem);
return queue_op_status::success;
}
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::try_pull(T& elem)
{
lock_guard<mutex> lk(super::mtx_);
return try_pull(lk, elem);
}
///////////////////////////
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::wait_pull(unique_lock<mutex>& lk, T& elem)
{
if (super::empty(lk))
{
if (super::closed(lk)) return queue_op_status::closed;
}
bool has_been_closed = wait_until_not_empty_time_reached_or_closed(lk);
if (has_been_closed) return queue_op_status::closed;
pull(lk, elem);
return queue_op_status::success;
}
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::wait_pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_);
return wait_pull(lk, elem);
}
// ///////////////////////////
// template <class T, class Clock>
// queue_op_status sync_timed_queue<T, Clock>::wait_pull(unique_lock<mutex> &lk, T& elem)
// {
// if (super::empty(lk))
// {
// if (super::closed(lk)) return queue_op_status::closed;
// }
// bool has_been_closed = super::wait_until_not_empty_or_closed(lk);
// if (has_been_closed) return queue_op_status::closed;
// pull(lk, elem);
// return queue_op_status::success;
// }
// template <class T>
// queue_op_status sync_timed_queue<T, Clock>::wait_pull(T& elem)
// {
// unique_lock<mutex> lk(super::mtx_);
// return wait_pull(lk, elem);
// }
///////////////////////////
template <class T, class Clock>
queue_op_status sync_timed_queue<T, Clock>::nonblocking_pull(T& elem)
{
unique_lock<mutex> lk(super::mtx_, try_to_lock);
if (! lk.owns_lock()) return queue_op_status::busy;
return try_pull(lk, elem);
}
} //end concurrent namespace
using concurrent::sync_timed_queue;
} //end boost namespace
#include <boost/config/abi_suffix.hpp>
#endif

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