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

Compare commits

...

89 Commits

Author SHA1 Message Date
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
83f877a238 Merge branch 'develop' 2015-12-08 06:30:55 +01:00
Vicente J. Botet Escriba
47f615d073 Merge branch 'develop' 2015-12-07 22:04:51 +01:00
Vicente J. Botet Escriba
7079a80edf Merge branch 'develop' 2015-11-24 23:03:35 +01:00
Vicente J. Botet Escriba
dbf28a4ac4 Merge branch 'develop' 2015-11-15 00:02:15 +01:00
Vicente J. Botet Escriba
2866734b15 Merge branch 'develop' 2015-10-29 11:33:17 +01:00
42 changed files with 308 additions and 185 deletions

View File

@@ -126,6 +126,8 @@ project boost/thread
<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)
@@ -316,3 +318,5 @@ lib boost_thread
<link>static:<define>BOOST_THREAD_USE_LIB=1
<conditional>@usage-requirements
;
boost-install boost_thread ;

View File

@@ -112,7 +112,7 @@ A question arises of which of these executors (or others) be included in this li
[////////////////////////]
[section:rationale Design Rationale]
The authors of Boost.Thread have taken a different approach respect to N3785. Instead of basing all the design on a abstract executor class we make executor concepts. We believe that this is the good direction as a static polymorphic executor can be seen as a dynamic polymorphic executor using a simple adaptor. We believe also that it would make the library more usable, and more convenient for users.
The authors of Boost.Thread have taken a different approach respect to N3785. Instead of basing all the design on an abstract executor class we make executor concepts. We believe that this is the good direction as a static polymorphic executor can be seen as a dynamic polymorphic executor using a simple adaptor. We believe also that it would make the library more usable, and more convenient for users.
The major design decisions concern deciding what a unit of work is, how to manage with units of work and time related functions in a polymorphic way.
@@ -364,8 +364,8 @@ A type `E` meets the `Executor` requirements if the following expressions are we
where
* `e` denotes a value of type `E`,
* `lc` denotes a lvalue referece of type `Closure`,
* `rc` denotes a rvalue referece of type `Closure`
* `lc` denotes a lvalue reference of type `Closure`,
* `rc` denotes a rvalue reference of type `Closure`
* `p` denotes a value of type `Predicate`
[/////////////////////////////////////]
@@ -388,7 +388,7 @@ If invoked closure throws an exception the executor will call std::terminate, as
[endsect]
[/////////////////////////////////////]
[section:submitrc `e.submit(lc);`]
[section:submitrc `e.submit(rc);`]
[variablelist
@@ -417,7 +417,7 @@ If invoked closure throws an exception the executor will call std::terminate, as
[[Return type:] [`void`.]]
[[Throws:] [Whatever exception that can be throw while ensuring the thread safety.]]
[[Throws:] [Whatever exception that can be thrown while ensuring the thread safety.]]
[[Exception safety:] [If an exception is thrown then the executor state is unmodified.]]
@@ -462,7 +462,7 @@ If invoked closure throws an exception the executor will call std::terminate, as
[variablelist
[[Requires:] [This must be called from an scheduled work]]
[[Requires:] [This must be called from a scheduled work]]
[[Effects:] [reschedule works until `p()`.]]
@@ -533,7 +533,7 @@ Executor abstract base class.
[variablelist
[[Effects:] [Constructs a executor. ]]
[[Effects:] [Constructs an executor. ]]
[[Throws:] [Nothing. ]]
@@ -600,7 +600,7 @@ Polymorphic adaptor of a model of Executor to an executor.
[variablelist
[[Effects:] [Constructs a executor_adaptor. ]]
[[Effects:] [Constructs an executor_adaptor. ]]
[[Throws:] [Nothing. ]]
@@ -1521,7 +1521,7 @@ A serial executor ensuring that there are no two work units that executes concur
[variablelist
[[Effects:] [Constructs a inline_executor. ]]
[[Effects:] [Constructs an inline_executor. ]]
[[Throws:] [Nothing. ]]
@@ -1709,7 +1709,7 @@ A user scheduled executor.
[variablelist
[[Effects:] [creates a executor that runs closures using one of its closure-executing methods. ]]
[[Effects:] [creates an executor that runs closures using one of its closure-executing methods. ]]
[[Throws:] [Whatever exception is thrown while initializing the needed resources. ]]

View File

@@ -1,6 +1,6 @@
[/
(C) Copyright 2007-11 Anthony Williams.
(C) Copyright 2011-15 Vicente J. Botet Escriba.
(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).
@@ -8,6 +8,73 @@
[section:changes History]
[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:]
@@ -26,14 +93,13 @@ Please take a look at [@http://www.boost.org/development/tests/master/developer/
* [@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 contination on undetermined thread
* [@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/3926 #3926] thread_specific_ptr + dlopen library causes a SIGSEGV.
* [@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
@@ -67,6 +133,7 @@ Please take a look at [@http://www.boost.org/development/tests/master/developer/
* [@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]

View File

@@ -81,7 +81,7 @@ When `BOOST_THREAD_VERSION>3` && defined BOOST_THREAD_PLATFORM_PTHREAD define `
[section:move Boost.Atomic]
Boost.Thread uses by default an Boost.Atomic in POSIX platforms to implement call_once..
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.

View File

@@ -267,7 +267,7 @@ The library provides un implicit conversion to an undefined type that can be use
explicit operator bool() const;
#endif
The user should use the lock.owns_lock() when a explicit conversion is required.
The user should use the lock.owns_lock() when an explicit conversion is required.
[section:bool_conversion `operator `['unspecified-bool-type]`() const`]
@@ -324,7 +324,7 @@ the library declare these types as
}
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
These macros allows to use 'future_errc' in almost all the cases as an scoped enum.
These macros allows to use 'future_errc' in almost all the cases as a scoped enum.
There are however some limitations:

View File

@@ -127,10 +127,10 @@
future<typename decay<T>::type> make_ready_future(T&& value); // EXTENSION
future<void> make_ready_future(); // EXTENSION
exceptional_ptr make_exceptional(exception_ptr ex); // EXTENSION
exceptional_ptr make_exceptional_future(exception_ptr ex); // EXTENSION
template <typename E>
exceptional_ptr make_exceptional(E ex); // EXTENSION
exceptional_ptr make_exceptional(); // EXTENSION
exceptional_ptr make_exceptional_future(E ex); // EXTENSION
exceptional_ptr make_exceptional_future(); // EXTENSION
template <typename T>
@@ -349,7 +349,7 @@ The object's `name` virtual function returns a pointer to the string "future".]]
// move support
__unique_future__(__unique_future__ && other) noexcept;
__unique_future__(__unique_future__<__unique_future__<R>>&& rhs); // EXTENSION
explicit __unique_future__(__unique_future__<__unique_future__<R>>&& rhs); // EXTENSION
__unique_future__& operator=(__unique_future__ && other) noexcept;
// factories
@@ -453,7 +453,7 @@ associated with `*this`. `other` is not associated with any shared state.]]
[///////////////////////////////////////////////////////////////////]
[section:unwrap_move_constructor Unwrap Move Constructor - EXTENSION]
__unique_future__(__unique_future__<__unique_future__<R>>&& other); // EXTENSION
explicit __unique_future__(__unique_future__<__unique_future__<R>>&& other); // EXTENSION
[warning This constructor is 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 :(]
@@ -848,7 +848,7 @@ stored exception, `false` otherwise.]]
[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready. If the result is not ready on
entry, and the result has a ['wait callback] set, that callback is invoked prior to waiting.]]
[[Returns:] [a exception_ptr, storring or not an exception.]]
[[Returns:] [an exception_ptr, storing or not an exception.]]
[[Remarks:] [The result of this function is not stable and the future could lost its exception even if the function returned a valid `exception_ptr` or vice-versa.]]
@@ -913,7 +913,7 @@ There are not too much tests yet, so it is possible that you can find out some t
[variablelist
[[Notes:] [The three functions differ only by input parameters. The first only takes a callable object which accepts a
future object as a parameter. The second function takes a executor as the first parameter and a callable object as
future object as a parameter. The second function takes an executor as the first parameter and a callable object as
the second parameter. The third function takes a launch policy as the first parameter and a callable object as the
second parameter.]]
@@ -1357,7 +1357,7 @@ stored exception, `false` otherwise.]]
[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready. If the result is not ready on
entry, and the result has a ['wait callback] set, that callback is invoked prior to waiting.]]
[[Returns:] [a exception_ptr, storring or not an exception.]]
[[Returns:] [an exception_ptr, storing or not an exception.]]
[[Throws:] [Whatever `mutex::lock()/mutex::unlock()` can throw.]]
@@ -2451,12 +2451,12 @@ Otherwise the value is copied to the shared state of the returned future.
[endsect]
[/////////////////////////////////////////////////////////////////////////////]
[section:make_exceptional Non-member function `make_exceptional()` EXTENSION]
[section:make_exceptional_future Non-member function `make_exceptional_future()` EXTENSION]
exceptional_ptr make_exceptional(exception_ptr ex); // EXTENSION
exceptional_ptr make_exceptional_future(exception_ptr ex); // EXTENSION
template <typename E>
exceptional_ptr make_exceptional(E ex); // EXTENSION
exceptional_ptr make_exceptional(); // EXTENSION
exceptional_ptr make_exceptional_future(E ex); // EXTENSION
exceptional_ptr make_exceptional_future(); // EXTENSION
[variablelist

View File

@@ -240,9 +240,9 @@ The following class describes a so-called monitor pattern.
template <
typename Lockable=mutex
>
class basic_monitor : protected basic_lockable_adapter<Lockable> { // behaves like an BasicLockable for the derived classes
class basic_monitor : protected basic_lockable_adapter<Lockable> { // behaves like a BasicLockable for the derived classes
protected:
typedef unspecified synchronizer; // is an strict lock guard
typedef unspecified synchronizer; // is a strict lock guard
};
[/shared_monitor]

View File

@@ -869,7 +869,7 @@ any other threads have shared ownership, blocks until exclusive ownership can be
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Precondition:] [The calling thread shall hold an upgrade lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread without blocking.
For this conversion to be successful, this thread must be the only thread holding any ownership of the lock.
@@ -893,7 +893,7 @@ If the conversion is not successful, the upgrade ownership of m is retained.]]
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Precondition:] [The calling thread shall hold an upgrade lock on the mutex.]]
[[Effects:] [If the tick period of `rel_time` is not exactly convertible to the native tick period, the duration shall be rounded up to the nearest native tick period.
The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread within the relative timeout specified by `rel_time`.
@@ -919,7 +919,7 @@ If the conversion is not successful, the upgrade ownership of m is retained.]]
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Precondition:] [The calling thread shall hold an upgrade lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread within the absolute timeout specified by `abs_time`.
If `abs_time` has already passed, the function attempts to obtain exclusive ownership without blocking (as if by calling `__try_unlock_upgrade_and_lock()`).
@@ -2150,7 +2150,7 @@ object passed to the constructor.]]
__nested_strict_lock is a model of __StrictLock.
A nested strict lock is a scoped lock guard ensuring a mutex is locked on its
scope, by taking ownership of an nesting lock, locking the mutex on construction if not already locked
scope, by taking ownership of a nesting lock, locking the mutex on construction if not already locked
and restoring the ownership to the nesting lock on destruction.

View File

@@ -150,7 +150,7 @@ This wrapper can be used to join the thread before destroying it.
[variablelist
[[Effects:] [Construct a internal thread in place.]]
[[Effects:] [Construct an internal thread in place.]]
[[Postconditions:] [`*this.t_` refers to the newly created thread of execution and `this->get_id()!=thread::id()`.]]
@@ -291,16 +291,14 @@ same non-deprecated interface with the exception of the construction.
[variablelist
[[Effects:] [Transfers ownership of the scoped_thread managed by `other` (if
any) to `*this`.
any) to `*this` after having called to `CallableThread()(t_)`.
- if defined `BOOST_THREAD_DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE`: If there was a `scoped_thread` previously associated with `*this` then that `scoped_thread` is detached, DEPRECATED
- if defined `BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE`: If the `scoped_thread` is joinable calls to std::terminate.
]]
[[Postconditions:] [`other->get_id()==thread::id()` and `get_id()` returns the value of `other.get_id()` prior to the assignment.]]
[[Throws:] [Nothing]]
[[Throws:] [Nothing: The `CallableThread()(t_)` should not throw when joining the thread as the scoped variable is on a scope outside the thread function.]]
]

View File

@@ -769,22 +769,14 @@ Closed queues add the following valid expressions
void push(const value_type& x);
void push(BOOST_THREAD_RV_REF(value_type) x);
void pull(value_type& x);
value_type pull();
queue_op_status try_push(const value_type& x);
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status try_pull(value_type& x);
queue_op_status nonblocking_push(const value_type& x);
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status nonblocking_pull(value_type& x);
queue_op_status wait_push(const value_type& x);
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status wait_pull_front(value_type& x);
};
@@ -812,24 +804,13 @@ Closed queues add the following valid expressions
// Modifiers
void close();
void push(const value_type& x);
void push(BOOST_THREAD_RV_REF(value_type) x);
void pull(value_type& x);
value_type pull();
queue_op_status try_push(const value_type& x);
queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status try_pull(value_type& x);
queue_op_status nonblocking_push(const value_type& x);
queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status nonblocking_pull(value_type& x);
queue_op_status wait_push(const value_type& x);
queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x);
queue_op_status wait_pull(value_type& x);
};

View File

@@ -156,7 +156,7 @@ object passed to the constructor.]]
};
}
`externally_locked_stream` cloaks a reference to an stream of type `Stream`, and actually
`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.

View File

@@ -63,7 +63,7 @@ Both forms of pointer dereference return a proxy object rather than a real refer
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 an 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.
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)
{

View File

@@ -8,10 +8,10 @@
[library Thread
[quickbook 1.5]
[version 4.6.0]
[version 4.7.1]
[authors [Williams, Anthony] [Botet Escriba, Vicente J.]]
[copyright 2007-11 Anthony Williams]
[copyright 2011-15 Vicente J. Botet Escriba]
[copyright 2011-16 Vicente J. Botet Escriba]
[purpose C++ Library for launching threads and synchronizing data between them]
[category text]
[license

View File

@@ -21,7 +21,7 @@
{
thread::id get_id() noexcept;
template<typename TimeDuration>
void yield() noexcept; // DEPRECATED
void yield() noexcept;
template <class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
template <class Rep, class Period>
@@ -289,9 +289,11 @@ You can use a thread_joiner to ensure that the thread has been joined at the thr
A running thread can be ['interrupted] by invoking the __interrupt__ member function of the corresponding __thread__ object. When the
interrupted thread next executes one of the specified __interruption_points__ (or if it is currently __blocked__ whilst executing one)
with interruption enabled, then a __thread_interrupted__ exception will be thrown in the interrupted thread. If not caught,
this will cause the execution of the interrupted thread to terminate. As with any other exception, the stack will be unwound, and
destructors for objects of automatic storage duration will be executed.
with interruption enabled, then a __thread_interrupted__ exception will be thrown in the interrupted thread. Unless this exception is
caught inside the interrupted thread's thread-main function, the stack unwinding process (as with any other exception) causes the
destructors with automatic storage duration to be executed. Unlike other exceptions, when __thread_interrupted__ is propagated out of
thread-main function, this does not cause the call to `std::terminate`; the effect is as though the thread-main function has returned
normally.
If a thread wishes to avoid being interrupted, it can create an instance of __disable_interruption__. Objects of this class disable
interruption for the thread that created them on construction, and restore the interruption state to whatever it was before on
@@ -711,7 +713,7 @@ are copied into internal storage for access by the new thread.]]]
[[Throws:] [Nothing.]]
[[Note:] [The reason to moving to std::terminate is that either implicitly detaching or joining a `joinable()` thread in its destructor could result in difficult to debug correctness (for `detach`) or performance (for `join`) bugs encountered only when an exception is raised. Thus the programmer must ensure that the destructor is never executed while the thread is still joinable. Join the thread before destroying or use an scoped thread.]]
[[Note:] [The reason to moving to std::terminate is that either implicitly detaching or joining a `joinable()` thread in its destructor could result in difficult to debug correctness (for `detach`) or performance (for `join`) bugs encountered only when an exception is raised. Thus the programmer must ensure that the destructor is never executed while the thread is still joinable. Join the thread before destroying or use a scoped thread.]]
]
@@ -953,7 +955,7 @@ a default-constructed __thread_id__.]]
[[Effects:] [If `*this` refers to a thread of execution, request that the thread will be interrupted the next time it enters one of
the predefined __interruption_points__ with interruption enabled, or if it is currently __blocked__ in a call to one of the
predefined __interruption_points__ with interruption enabled .]]
predefined __interruption_points__ with interruption enabled. Otherwise do noting.]]
[[Throws:] [Nothing]]
@@ -1304,7 +1306,7 @@ instances of __thread_id__ `a` and `b` is the same if `a==b`, and different if `
[variablelist
[[Effects:] [Stores the stack size to be used to create a thread. This is an hint that the implementation can choose a better size if to small or too big or not aligned to a page.]]
[[Effects:] [Stores the stack size to be used to create a thread. This is a hint that the implementation can choose a better size if to small or too big or not aligned to a page.]]
[[Postconditions:] [`this-> get_stack_size()` returns the chosen stack size.]]

View File

@@ -44,7 +44,7 @@ int main()
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
boost::future<int> inner_future = boost::async(boost::launch::async, &p2);
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;

View File

@@ -145,7 +145,7 @@ namespace boost
unsigned int count,
BOOST_THREAD_RV_REF(F) funct,
typename enable_if<
typename is_void<typename result_of<F>::type>::type, dummy*
typename is_void<typename result_of<F()>::type>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
@@ -160,7 +160,7 @@ namespace boost
unsigned int count,
F &funct,
typename enable_if<
typename is_void<typename result_of<F>::type>::type, dummy*
typename is_void<typename result_of<F()>::type>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
@@ -176,7 +176,7 @@ namespace boost
unsigned int count,
BOOST_THREAD_RV_REF(F) funct,
typename enable_if<
typename is_same<typename result_of<F>::type, unsigned int>::type, dummy*
typename is_same<typename result_of<F()>::type, unsigned int>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
@@ -189,7 +189,7 @@ namespace boost
unsigned int count,
F& funct,
typename enable_if<
typename is_same<typename result_of<F>::type, unsigned int>::type, dummy*
typename is_same<typename result_of<F()>::type, unsigned int>::type, dummy*
>::type=0
)
: m_count(check_counter(count)),
@@ -225,6 +225,7 @@ namespace boost
m_generation++;
m_count = static_cast<unsigned int>(fct_());
BOOST_ASSERT(m_count != 0);
lock.unlock();
m_cond.notify_all();
return true;
}

View File

@@ -96,7 +96,6 @@ namespace boost
leavers_(0)
{
}
template <typename F>
completion_latch(std::size_t count, void(*funct)()) :
count_(count), funct_(funct), waiters_(0), leavers_(0)
{

View File

@@ -76,26 +76,15 @@ namespace concurrent
// Modifiers
void close() { queue->close(); }
void push(const value_type& x) { queue->push_front(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_front(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_front(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_front(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_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)); }
};

View File

@@ -69,7 +69,7 @@ namespace detail
class sync_timed_queue
: private sync_priority_queue<detail::scheduled_type<T, Clock> >
{
typedef detail::scheduled_type<T> stype;
typedef detail::scheduled_type<T, Clock> stype;
typedef sync_priority_queue<stype> super;
public:
typedef T value_type;
@@ -229,7 +229,8 @@ namespace detail
if (super::closed(lk)) return true;
while (! super::empty(lk)) {
if (! time_not_reached(lk)) return false;
super::not_empty_.wait_until(lk, super::data_.top().time);
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;
@@ -245,7 +246,8 @@ namespace detail
while (time_not_reached(lk))
{
super::throw_if_closed(lk);
super::not_empty_.wait_until(lk,super::data_.top().time);
time_point tp = super::data_.top().time;
super::not_empty_.wait_until(lk,tp);
super::wait_until_not_empty(lk);
}
return pull(lk);
@@ -260,7 +262,7 @@ namespace detail
while (time_not_reached(lk))
{
super::throw_if_closed(lk);
if (queue_op_status::timeout == super::not_empty_.wait_until(lk, tpmin)) {
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;
}

View File

@@ -100,8 +100,8 @@
#if !defined BOOST_THREAD_VERSION
#define BOOST_THREAD_VERSION 2
#else
#if BOOST_THREAD_VERSION!=2 && BOOST_THREAD_VERSION!=3 && BOOST_THREAD_VERSION!=4
#error "BOOST_THREAD_VERSION must be 2, 3 or 4"
#if BOOST_THREAD_VERSION!=2 && BOOST_THREAD_VERSION!=3 && BOOST_THREAD_VERSION!=4 && BOOST_THREAD_VERSION!=5
#error "BOOST_THREAD_VERSION must be 2, 3, 4 or 5"
#endif
#endif
@@ -304,6 +304,13 @@
#endif // BOOST_THREAD_VERSION>=4
#if BOOST_THREAD_VERSION>=5
//#define BOOST_THREAD_FUTURE_BLOCKING
#else
//#define BOOST_THREAD_FUTURE_BLOCKING
#define BOOST_THREAD_ASYNC_FUTURE_WAITS
#endif
// INTERRUPTIONS
#if ! defined BOOST_THREAD_PROVIDES_INTERRUPTIONS \
&& ! defined BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS

View File

@@ -32,7 +32,7 @@ namespace boost
/// executor is not copyable.
BOOST_THREAD_NO_COPYABLE(executor_ref)
executor_ref(Executor& ex) : ex(ex) {}
executor_ref(Executor& ex_) : ex(ex_) {}
/**
* \par Effects
@@ -98,9 +98,9 @@ namespace boost
typedef executors::work work;
template<typename Executor>
generic_executor_ref(Executor& ex)
//: ex(make_shared<executor_ref<Executor> >(ex)) // todo check why this doesn't works with C++03
: ex( new executor_ref<Executor>(ex) )
generic_executor_ref(Executor& ex_)
//: ex(make_shared<executor_ref<Executor> >(ex_)) // todo check why this doesn't works with C++03
: ex( new executor_ref<Executor>(ex_) )
{
}

View File

@@ -14,7 +14,6 @@
// due to boost::exception::exception_ptr dependency
//#define BOOST_THREAD_CONTINUATION_SYNC
#define BOOST_THREAD_FUTURE_BLOCKING
#ifndef BOOST_NO_EXCEPTIONS
@@ -177,8 +176,8 @@ namespace boost
ex()
{}
shared_state_base(exceptional_ptr const& ex):
exception(ex.ptr_),
shared_state_base(exceptional_ptr const& ex_):
exception(ex_.ptr_),
done(true),
is_valid_(true),
is_deferred_(false),
@@ -825,6 +824,12 @@ namespace boost
{
#ifdef BOOST_THREAD_FUTURE_BLOCKING
join();
#elif defined BOOST_THREAD_ASYNC_FUTURE_WAITS
unique_lock<boost::mutex> lk(this->mutex);
while(!this->done)
{
this->waiters.wait(lk);
}
#endif
}
@@ -853,9 +858,9 @@ namespace boost
void init(BOOST_THREAD_FWD_REF(Fp) f)
{
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward<Fp>(f));
this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward<Fp>(f));
#else
thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward<Fp>(f)).detach();
boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward<Fp>(f)).detach();
#endif
}
@@ -878,9 +883,9 @@ namespace boost
void init(BOOST_THREAD_FWD_REF(Fp) f)
{
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f));
this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f));
#else
thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach();
boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach();
#endif
}
@@ -904,9 +909,9 @@ namespace boost
void init(BOOST_THREAD_FWD_REF(Fp) f)
{
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f));
this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f));
#else
thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach();
boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach();
#endif
}
@@ -1634,7 +1639,7 @@ namespace boost
base_type(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))))
{
}
inline BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R> >) other); // EXTENSION
inline explicit BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R> >) other); // EXTENSION
explicit BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(shared_future<R>) other) :
base_type(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))))
@@ -4379,9 +4384,9 @@ namespace detail
void launch_continuation() {
#if defined BOOST_THREAD_FUTURE_BLOCKING
boost::lock_guard<boost::mutex> lk(this->mutex);
this->thr_ = thread(&future_async_continuation_shared_state::run, static_shared_from_this(this));
this->thr_ = boost::thread(&future_async_continuation_shared_state::run, static_shared_from_this(this));
#else
thread(&base_type::run, static_shared_from_this(this)).detach();
boost::thread(&base_type::run, static_shared_from_this(this)).detach();
#endif
}
};
@@ -4498,9 +4503,9 @@ namespace detail {
void launch_continuation() {
#if defined BOOST_THREAD_FUTURE_BLOCKING
boost::lock_guard<boost::mutex> lk(this->mutex);
this->thr_ = thread(&base_type::run, static_shared_from_this(this));
this->thr_ = boost::thread(&base_type::run, static_shared_from_this(this));
#else
thread(&base_type::run, static_shared_from_this(this)).detach();
boost::thread(&base_type::run, static_shared_from_this(this)).detach();
#endif
}
};
@@ -4767,17 +4772,17 @@ namespace detail {
#endif
} else if (underlying_cast<int>(policy) & int(launch::inherit)) {
launch policy = this->launch_policy(lock);
if (underlying_cast<int>(policy) & int(launch::async)) {
launch policy_ = this->launch_policy(lock);
if (underlying_cast<int>(policy_) & int(launch::async)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
lock, boost::move(*this), boost::forward<F>(func)
)));
} else if (underlying_cast<int>(policy) & int(launch::deferred)) {
} else if (underlying_cast<int>(policy_) & int(launch::deferred)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
lock, boost::move(*this), boost::forward<F>(func)
)));
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
} else if (underlying_cast<int>(policy_) & int(launch::executor)) {
assert(this->future_->get_executor());
typedef executor Ex;
Ex& ex = *(this->future_->get_executor());
@@ -4888,22 +4893,22 @@ namespace detail {
)));
#endif
} else if (underlying_cast<int>(policy) & int(launch::inherit)) {
launch policy = this->launch_policy(lock);
launch policy_ = this->launch_policy(lock);
if (underlying_cast<int>(policy) & int(launch::async)) {
if (underlying_cast<int>(policy_) & int(launch::async)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
lock, boost::move(*this), boost::forward<F>(func)
)));
} else if (underlying_cast<int>(policy) & int(launch::deferred)) {
} else if (underlying_cast<int>(policy_) & int(launch::deferred)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
lock, boost::move(*this), boost::forward<F>(func)
)));
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
} else if (underlying_cast<int>(policy_) & int(launch::sync)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
lock, boost::move(*this), boost::forward<F>(func)
)));
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
} else if (underlying_cast<int>(policy_) & int(launch::executor)) {
assert(this->future_->get_executor());
typedef executor Ex;
Ex& ex = *(this->future_->get_executor());
@@ -5015,21 +5020,21 @@ namespace detail {
#endif
} else if (underlying_cast<int>(policy) & int(launch::inherit)) {
launch policy = this->launch_policy(lock);
if (underlying_cast<int>(policy) & int(launch::async)) {
launch policy_ = this->launch_policy(lock);
if (underlying_cast<int>(policy_) & int(launch::async)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state<shared_future<R>, future_type>(
lock, *this, boost::forward<F>(func)
)));
} else if (underlying_cast<int>(policy) & int(launch::deferred)) {
} else if (underlying_cast<int>(policy_) & int(launch::deferred)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state<shared_future<R>, future_type>(
lock, *this, boost::forward<F>(func)
)));
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
} else if (underlying_cast<int>(policy_) & int(launch::sync)) {
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state<shared_future<R>, future_type>(
lock, *this, boost::forward<F>(func)
)));
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
} else if (underlying_cast<int>(policy_) & int(launch::executor)) {
typedef executor Ex;
Ex& ex = *(this->future_->get_executor());
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_executor_continuation_shared_state<Ex, shared_future<R>, future_type>(ex,
@@ -5311,9 +5316,9 @@ namespace detail
return;
}
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_when_all_vector_shared_state::run, this->shared_from_this());
this->thr_ = boost::thread(&future_when_all_vector_shared_state::run, this->shared_from_this());
#else
thread(&future_when_all_vector_shared_state::run, this->shared_from_this()).detach();
boost::thread(&future_when_all_vector_shared_state::run, this->shared_from_this()).detach();
#endif
}
@@ -5382,9 +5387,9 @@ namespace detail
}
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_when_any_vector_shared_state::run, this->shared_from_this());
this->thr_ = boost::thread(&future_when_any_vector_shared_state::run, this->shared_from_this());
#else
thread(&future_when_any_vector_shared_state::run, this->shared_from_this()).detach();
boost::thread(&future_when_any_vector_shared_state::run, this->shared_from_this()).detach();
#endif
}
@@ -5489,9 +5494,9 @@ namespace detail
return;
}
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_when_all_tuple_shared_state::run, this->shared_from_this());
this->thr_ = boost::thread(&future_when_all_tuple_shared_state::run, this->shared_from_this());
#else
thread(&future_when_all_tuple_shared_state::run, this->shared_from_this()).detach();
boost::thread(&future_when_all_tuple_shared_state::run, this->shared_from_this()).detach();
#endif
}
@@ -5560,9 +5565,9 @@ namespace detail
}
#ifdef BOOST_THREAD_FUTURE_BLOCKING
this->thr_ = thread(&future_when_any_tuple_shared_state::run, this->shared_from_this());
this->thr_ = boost::thread(&future_when_any_tuple_shared_state::run, this->shared_from_this());
#else
thread(&future_when_any_tuple_shared_state::run, this->shared_from_this()).detach();
boost::thread(&future_when_any_tuple_shared_state::run, this->shared_from_this()).detach();
#endif
}

View File

@@ -934,7 +934,7 @@ namespace boost
if (m == 0)
{
boost::throw_exception(
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex"));
}
if (owns_lock())
{
@@ -949,7 +949,7 @@ namespace boost
if (m == 0)
{
boost::throw_exception(
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex"));
}
if (owns_lock())
{
@@ -964,7 +964,7 @@ namespace boost
if (m == 0)
{
boost::throw_exception(
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex"));
}
if (!owns_lock())
{
@@ -980,11 +980,11 @@ namespace boost
{
if(m==0)
{
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex"));
}
if(owns_lock())
{
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex"));
}
is_locked=m->try_lock_upgrade_for(rel_time);
return is_locked;
@@ -994,11 +994,11 @@ namespace boost
{
if(m==0)
{
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex"));
}
if(owns_lock())
{
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex"));
}
is_locked=m->try_lock_upgrade_until(abs_time);
return is_locked;
@@ -1080,7 +1080,7 @@ namespace boost
//std-2104 unique_lock move-assignment should not be noexcept
upgrade_to_unique_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_to_unique_lock<Mutex> BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT
{
upgrade_to_unique_lock temp(other);
upgrade_to_unique_lock temp(::boost::move(other));
swap(temp);
return *this;
}
@@ -1167,7 +1167,7 @@ private unique_lock<Mutex>
#endif
try_lock_wrapper& operator=(BOOST_THREAD_RV_REF_BEG try_lock_wrapper<Mutex> BOOST_THREAD_RV_REF_END other)
{
try_lock_wrapper temp(other);
try_lock_wrapper temp(::boost::move(other));
swap(temp);
return *this;
}

View File

@@ -10,6 +10,7 @@
#include <boost/thread/lock_algorithms.hpp>
#include <boost/thread/lock_types.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/thread/shared_lock_guard.hpp>
#include <boost/thread/lockable_traits.hpp>
#include <boost/thread/lock_options.hpp>

View File

@@ -336,14 +336,15 @@ namespace boost
cv_status::timeout;
}
template <class lock_type>
inline cv_status wait_until(
unique_lock<mutex>& lk,
lock_type& lock,
chrono::time_point<chrono::steady_clock, chrono::nanoseconds> tp)
{
using namespace chrono;
nanoseconds d = tp.time_since_epoch();
timespec ts = boost::detail::to_timespec(d);
if (do_wait_until(lk, ts)) return cv_status::no_timeout;
if (do_wait_until(lock, ts)) return cv_status::no_timeout;
else return cv_status::timeout;
}
@@ -391,7 +392,7 @@ namespace boost
private: // used by boost::thread::try_join_until
template <class lock_type>
inline bool do_wait_until(
bool do_wait_until(
lock_type& m,
struct timespec const &timeout)
{

View File

@@ -75,8 +75,9 @@ namespace boost
BOOST_THREAD_NO_COPYABLE(condition_variable)
condition_variable()
{
int res;
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
int res=pthread_mutex_init(&internal_mutex,NULL);
res=pthread_mutex_init(&internal_mutex,NULL);
if(res)
{
boost::throw_exception(thread_resource_error(res, "boost::condition_variable::condition_variable() constructor failed in pthread_mutex_init"));

View File

@@ -269,13 +269,13 @@ namespace boost
// avoid other threads to lock, lock_upgrade or lock_shared, so only this thread is notified.
state.upgrade=false;
state.exclusive=true;
lk.unlock();
//lk.unlock();
upgrade_cond.notify_one();
}
else
{
state.exclusive_waiting_blocked=false;
lk.unlock();
//lk.unlock();
}
release_waiters();
}

View File

@@ -228,7 +228,7 @@ namespace boost
namespace this_thread
{
namespace hiden
namespace hidden
{
void BOOST_THREAD_DECL sleep_for(const timespec& ts);
void BOOST_THREAD_DECL sleep_until(const timespec& ts);
@@ -240,14 +240,14 @@ namespace boost
inline
void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns)
{
return boost::this_thread::hiden::sleep_for(boost::detail::to_timespec(ns));
return boost::this_thread::hidden::sleep_for(boost::detail::to_timespec(ns));
}
#endif
#endif // BOOST_THREAD_USES_CHRONO
namespace no_interruption_point
{
namespace hiden
namespace hidden
{
void BOOST_THREAD_DECL sleep_for(const timespec& ts);
void BOOST_THREAD_DECL sleep_until(const timespec& ts);
@@ -259,7 +259,7 @@ namespace boost
inline
void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns)
{
return boost::this_thread::no_interruption_point::hiden::sleep_for(boost::detail::to_timespec(ns));
return boost::this_thread::no_interruption_point::hidden::sleep_for(boost::detail::to_timespec(ns));
}
#endif
#endif // BOOST_THREAD_USES_CHRONO
@@ -275,7 +275,7 @@ namespace boost
#endif
inline void sleep(system_time const& abs_time)
{
return boost::this_thread::hiden::sleep_until(boost::detail::to_timespec(abs_time));
return boost::this_thread::hidden::sleep_until(boost::detail::to_timespec(abs_time));
}
template<typename TimeDuration>

View File

@@ -197,6 +197,9 @@ namespace boost
*/
scoped_thread& operator=(BOOST_RV_REF(scoped_thread) x)
{
CallableThread on_destructor;
on_destructor(t_);
t_ = boost::move(BOOST_THREAD_RV(x).t_);
return *this;
}

View File

@@ -43,9 +43,9 @@ namespace boost
{
void operator()(thread& t)
{
t.interrupt();
if (t.joinable())
{
t.interrupt();
t.join();
}
}

View File

@@ -16,6 +16,7 @@
#include <boost/assert.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/detail/interlocked.hpp>
#include <boost/detail/winapi/config.hpp>
//#include <boost/detail/winapi/synchronization.hpp>
#include <algorithm>

View File

@@ -42,6 +42,7 @@ namespace boost
}
}
#if defined BOOST_THREAD_PATCH
const pthread_once_t pthread_once_init_value=PTHREAD_ONCE_INIT;
struct BOOST_THREAD_DECL delete_epoch_tss_key_on_dlclose_t
{
@@ -52,11 +53,15 @@ namespace boost
{
if(memcmp(&epoch_tss_key_flag, &pthread_once_init_value, sizeof(pthread_once_t)))
{
void* data = pthread_getspecific(epoch_tss_key);
if (data)
delete_epoch_tss_data(data);
pthread_key_delete(epoch_tss_key);
}
}
};
delete_epoch_tss_key_on_dlclose_t delete_epoch_tss_key_on_dlclose;
#endif
}
uintmax_atomic_t& get_once_per_thread_epoch()

View File

@@ -115,6 +115,7 @@ namespace boost
}
}
#if defined BOOST_THREAD_PATCH
struct delete_current_thread_tls_key_on_dlclose_t
{
delete_current_thread_tls_key_on_dlclose_t()
@@ -125,12 +126,15 @@ namespace boost
const boost::once_flag uninitialized = BOOST_ONCE_INIT;
if (memcmp(&current_thread_tls_init_flag, &uninitialized, sizeof(boost::once_flag)))
{
void* data = pthread_getspecific(current_thread_tls_key);
if (data)
tls_destructor(data);
pthread_key_delete(current_thread_tls_key);
}
}
};
delete_current_thread_tls_key_on_dlclose_t delete_current_thread_tls_key_on_dlclose;
#endif
void create_current_thread_tls_key()
{
BOOST_VERIFY(!pthread_key_create(&current_thread_tls_key,&tls_destructor));
@@ -426,7 +430,7 @@ namespace boost
{
namespace no_interruption_point
{
namespace hiden
namespace hidden
{
void BOOST_THREAD_DECL sleep_for(const timespec& ts)
{
@@ -486,7 +490,7 @@ namespace boost
}
}
namespace hiden
namespace hidden
{
void BOOST_THREAD_DECL sleep_for(const timespec& ts)
{
@@ -499,7 +503,7 @@ namespace boost
}
else
{
boost::this_thread::no_interruption_point::hiden::sleep_for(ts);
boost::this_thread::no_interruption_point::hidden::sleep_for(ts);
}
}
@@ -514,10 +518,10 @@ namespace boost
}
else
{
boost::this_thread::no_interruption_point::hiden::sleep_until(ts);
boost::this_thread::no_interruption_point::hidden::sleep_until(ts);
}
}
} // hiden
} // hidden
} // this_thread
namespace this_thread
@@ -538,7 +542,7 @@ namespace boost
timespec ts;
ts.tv_sec= 0;
ts.tv_nsec= 0;
hiden::sleep_for(ts);
hidden::sleep_for(ts);
# endif
}
}

View File

@@ -5,15 +5,9 @@
// (C) Copyright 2007 David Deakins
// (C) Copyright 2011-2013 Vicente J. Botet Escriba
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x400
#endif
#ifndef WINVER
#define WINVER 0x400
#endif
//#define BOOST_THREAD_VERSION 3
#include <boost/detail/winapi/config.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/once.hpp>
#include <boost/thread/tss.hpp>
@@ -24,6 +18,7 @@
#include <boost/cstdint.hpp>
#if defined BOOST_THREAD_USES_DATETIME
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/thread/thread_time.hpp>
#endif
#include <boost/thread/csbl/memory/unique_ptr.hpp>
#include <memory>
@@ -467,7 +462,7 @@ namespace boost
#if defined BOOST_THREAD_USES_DATETIME
bool thread::timed_join(boost::system_time const& wait_until)
{
return do_try_join_until(get_milliseconds_until(wait_until));
return do_try_join_until(boost::detail::get_milliseconds_until(wait_until));
}
#endif
bool thread::do_try_join_until_noexcept(uintmax_t milli, bool& res)

View File

@@ -3,6 +3,7 @@
// 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/detail/winapi/config.hpp>
#include <boost/thread/detail/config.hpp>
@@ -10,7 +11,6 @@
#include <boost/thread/detail/tss_hooks.hpp>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if defined(__BORLANDC__)

View File

@@ -7,6 +7,7 @@
// 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/detail/winapi/config.hpp>
#include <boost/thread/detail/config.hpp>
#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB)
@@ -77,7 +78,6 @@ extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -112,7 +112,7 @@ extern BOOL (WINAPI * const _pDefaultRawDllMainOrig)(HANDLE, DWORD, LPVOID) = NU
//Definitions required by implementation
#if (_MSC_VER < 1300) // 1300 == VC++ 7.0
#if (_MSC_VER < 1300) || (_MSC_VER > 1900) // 1300 == VC++ 7.0, 1900 == VC++ 14.0
typedef void (__cdecl *_PVFV)();
#define INIRETSUCCESS
#define PVAPI void __cdecl

View File

@@ -964,7 +964,8 @@ rule thread-compile ( sources : reqs * : name )
#[ thread-run test_11499.cpp ]
#[ thread-run test_11611.cpp ]
#[ thread-run test_11818.cpp ]
[ thread-run test_11796.cpp ]
#[ thread-run test_11796.cpp ]
[ thread-run test_12293.cpp ]
;

View File

@@ -12,7 +12,7 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// <boost/thread/detail/async_func.hpp>
// <boost/thread/detail/invoker.hpp>
#include <boost/thread/detail/invoker.hpp>
#include <boost/detail/lightweight_test.hpp>

View File

@@ -12,14 +12,9 @@
// 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)
// <boost/thread/detail/invoker.hpp>
#if ! defined BOOST_NO_CXX11_DECLTYPE
//#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/thread/detail/async_func.hpp>
#include <boost/thread/detail/invoker.hpp>
#include <boost/detail/lightweight_test.hpp>
int count = 0;

61
test/test_12293.cpp Normal file
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)
#define BOOST_THREAD_VERSION 4
// BoostFutureTest.cpp : Defines the entry point for the console application.
//
#include <iostream>
// boost version 1.60.0
// has the following set.
#define BOOST_THREAD_VERSION 4
// #define BOOST_THREAD_PROVIDES_EXECUTORS
#include <boost/thread/future.hpp>
int main()
{
int value = 0;
int tmpValue = 0;
boost::promise<void> promise1;
boost::promise<void> promise2;
auto future1 = promise1.get_future();
auto waitFuture = future1.then([&tmpValue, &promise2](boost::future<void> future){
assert(future.is_ready()); // this works correctly and is ready.
auto fut = boost::async(boost::launch::async, [&promise2, &tmpValue](){
boost::this_thread::sleep_for(boost::chrono::seconds(1));
tmpValue = 1;
promise2.set_value();
std::cout << "Step 2 "<< std::endl; // should print 1 but prints 0
});
std::cout << "Step 1 "<< std::endl; // should print 1 but prints 0
return promise2.get_future();
//return ;
}).then([&value, &tmpValue](boost::future<boost::future<void>> future){
//}).then([&value, &tmpValue](boost::future<void> future){
// error: no matching function for call to boost::future<boost::future<void> >::then(main()::<lambda(boost::future<void>)>)
// as expected
assert(future.is_ready()); // this doesn't work correctly and is not ready.
value = tmpValue;
});
promise1.set_value();
waitFuture.wait();
std::cout << "value = " << value << std::endl; // should print 1 but prints 0
return 0;
}

View File

@@ -33,7 +33,7 @@ inline void* operator new(std::size_t s)
void* operator new(std::size_t s) throw (std::bad_alloc)
#endif
{
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
//std::cout << __FILE__ << ":" << __LINE__ << std::endl;
if (throw_one == 0) throw std::bad_alloc();
--throw_one;
return std::malloc(s);
@@ -45,7 +45,7 @@ inline void operator delete(void* p)
inline void operator delete(void* p) throw ()
#endif
{
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
//std::cout << __FILE__ << ":" << __LINE__ << std::endl;
std::free(p);
}

View File

@@ -33,7 +33,7 @@ void* operator new(std::size_t s)
void* operator new(std::size_t s) throw (std::bad_alloc)
#endif
{
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
//std::cout << __FILE__ << ":" << __LINE__ << std::endl;
if (throw_one == 0) throw std::bad_alloc();
--throw_one;
return std::malloc(s);
@@ -45,7 +45,7 @@ void operator delete(void* p)
void operator delete(void* p) throw ()
#endif
{
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
//std::cout << __FILE__ << ":" << __LINE__ << std::endl;
std::free(p);
}