Compare commits

...

34 Commits

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

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

Updated environment setup scripts for better performance and
reliability.
2026-07-01 18:43:24 +03:00
Andrey Semashev 375ba39cf9 Fixed code indentation. 2026-06-29 13:19:38 +03:00
Andrey Semashev 48929e4281 Added missing includes of no_exceptions_support.hpp. 2026-06-29 13:13:29 +03:00
Andrey Semashev 07b93da337 Merge pull request #419 from mkruskal-google/patch-1
Use no-exceptions-friendly macros for try/catch block
2026-06-29 13:06:46 +03:00
Mike Kruskal 072ee46e8a Use no-exceptions-friendly macros for try/catch block
This fixes build breakages when -fno-exceptions is used
2026-06-17 21:03:48 -07:00
203 changed files with 3082 additions and 1835 deletions
+1193 -92
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -112,21 +112,21 @@ int main()
#if __cplusplus > 201103L
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
int i = 0;
boost::future<int&> f = boost::make_ready_future(std::ref(i));
int x = 0;
boost::future<int&> f = boost::make_ready_future(std::ref(x));
std::cout << f.get() << std::endl;
}
#endif
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
int i = 0;
boost::future<int&> f = boost::make_ready_future(boost::ref(i));
int x = 0;
boost::future<int&> f = boost::make_ready_future(boost::ref(x));
std::cout << f.get() << std::endl;
}
{
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
const int i = 0;
boost::future<int const&> f = boost::make_ready_future(boost::cref(i));
const int x = 0;
boost::future<int const&> f = boost::make_ready_future(boost::cref(x));
std::cout << f.get() << std::endl;
}
{
@@ -142,12 +142,12 @@ int main()
}
catch (std::exception& ex)
{
std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
std::cout << "ERRORRRRR " << ex.what() << std::endl;
return 1;
}
catch (...)
{
std::cout << "ERRORRRRR "<<"ERRORRRRR exception thrown" << std::endl;
std::cout << "ERRORRRRR ERRORRRRR exception thrown" << std::endl;
return 2;
}
return 0;
+4 -4
View File
@@ -8,7 +8,7 @@
#include <boost/thread/thread.hpp>
#include <iostream>
boost::mutex io_mutex; // The iostreams are not guaranteed to be thread-safe!
boost::mutex g_io_mutex; // The iostreams are not guaranteed to be thread-safe!
class counter
{
@@ -25,12 +25,12 @@ private:
int count;
};
counter c;
counter g_counter;
void change_count()
{
int i = c.increment();
boost::unique_lock<boost::mutex> scoped_lock(io_mutex);
int i = g_counter.increment();
boost::unique_lock<boost::mutex> scoped_lock(g_io_mutex);
std::cout << "count == " << i << std::endl;
}
+8 -8
View File
@@ -10,23 +10,23 @@
#include <boost/thread/once.hpp>
#include <cassert>
int value=0;
int g_value=0;
#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
static boost::once_flag once;
//static boost::once_flag once2 = BOOST_ONCE_INIT;
static boost::once_flag g_once;
//static boost::once_flag g_once2 = BOOST_ONCE_INIT;
#else
static boost::once_flag once = BOOST_ONCE_INIT;
//static boost::once_flag once2 = once;
static boost::once_flag g_once = BOOST_ONCE_INIT;
//static boost::once_flag g_once2 = g_once;
#endif
void init()
{
++value;
++g_value;
}
void thread_proc()
{
boost::call_once(&init, once);
boost::call_once(&init, g_once);
}
int main()
@@ -35,5 +35,5 @@ int main()
for (int i=0; i<5; ++i)
threads.create_thread(&thread_proc);
threads.join_all();
assert(value == 1);
assert(g_value == 1);
}
+3
View File
@@ -54,6 +54,7 @@ void consumer(
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull(r);
//sbq >> r;
@@ -77,6 +78,7 @@ void consumer2(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
@@ -97,6 +99,7 @@ void consumer3(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
+3
View File
@@ -57,6 +57,7 @@ void consumer(
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull(r);
//sbq >> r;
@@ -80,6 +81,7 @@ void consumer2(the_ostream &/*mos*/, boost::queue_front<int> sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull(r);
if (queue_op_status::closed == st) break;
@@ -100,6 +102,7 @@ void consumer3(the_ostream &/*mos*/, boost::queue_front<int> sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status res = sbq.wait_pull(r);
if (res==queue_op_status::closed) break;
+2
View File
@@ -55,6 +55,7 @@ void consumer(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
sbq.pull_front(r);
//sbq >> r;
@@ -77,6 +78,7 @@ void consumer2(the_ostream &/*mos*/, boost::sync_bounded_queue<int> & sbq)
try {
for(int i=0; ;++i)
{
(void)i;
int r;
queue_op_status st = sbq.try_pull_front(r);
if (queue_op_status::closed == st) break;
+2 -2
View File
@@ -28,11 +28,11 @@ private:
int count;
};
counter c;
counter g_counter;
void change_count()
{
//std::cout << "count == " << c.increment() << std::endl;
//std::cout << "count == " << g_counter.increment() << std::endl;
}
int main(int, char*[])
+1
View File
@@ -26,6 +26,7 @@ struct func
int& i;
func(int& i_):i(i_){}
func(func const& that):i(that.i){}
void operator()()
{
+20 -20
View File
@@ -28,9 +28,9 @@ enum game_state
BOTH_PLAYERS_GONE
};
int state;
boost::mutex mutex;
boost::condition cond;
int g_state;
boost::mutex g_mutex;
boost::condition g_cond;
const char* player_name(int state)
{
@@ -44,29 +44,29 @@ const char* player_name(int state)
void player(int active)
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
int other = active == PLAYER_A ? PLAYER_B : PLAYER_A;
while (state < GAME_OVER)
while (g_state < GAME_OVER)
{
//std::cout << player_name(active) << ": Play." << std::endl;
state = other;
cond.notify_all();
g_state = other;
g_cond.notify_all();
do
{
cond.wait(lock);
if (state == other)
g_cond.wait(lock);
if (g_state == other)
{
std::cout << "---" << player_name(active)
<< ": Spurious wakeup!" << std::endl;
}
} while (state == other);
} while (g_state == other);
}
++state;
++g_state;
std::cout << player_name(active) << ": Gone." << std::endl;
cond.notify_all();
g_cond.notify_all();
}
struct thread_adapt
@@ -100,7 +100,7 @@ private:
int main()
{
state = START;
g_state = START;
boost::thread thrda(&player, PLAYER_A);
boost::thread thrdb(&player, PLAYER_B);
@@ -110,22 +110,22 @@ int main()
xt.sec += 1;
boost::thread::sleep(xt);
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "---Noise ON..." << std::endl;
}
for (int i = 0; i < 10; ++i)
cond.notify_all();
g_cond.notify_all();
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "---Noise OFF..." << std::endl;
state = GAME_OVER;
cond.notify_all();
g_state = GAME_OVER;
g_cond.notify_all();
do
{
cond.wait(lock);
} while (state != BOTH_PLAYERS_GONE);
g_cond.wait(lock);
} while (g_state != BOTH_PLAYERS_GONE);
}
std::cout << "GAME OVER" << std::endl;
+11 -12
View File
@@ -8,23 +8,22 @@
#include <iostream>
#include <boost/detail/lightweight_test.hpp>
int count = 0;
boost::mutex mutex;
int g_count = 0;
boost::mutex g_mutex;
void increment_count()
{
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "count = " << ++count << std::endl;
boost::unique_lock<boost::mutex> lock(g_mutex);
std::cout << "count = " << ++g_count << std::endl;
}
boost::thread_group threads2;
boost::thread* th2 = 0;
boost::thread_group g_threads2;
void increment_count_2()
{
boost::unique_lock<boost::mutex> lock(mutex);
BOOST_TEST(threads2.is_this_thread_in());
std::cout << "count = " << ++count << std::endl;
boost::unique_lock<boost::mutex> lock(g_mutex);
BOOST_TEST(g_threads2.is_this_thread_in());
std::cout << "count = " << ++g_count << std::endl;
}
int main()
@@ -63,11 +62,11 @@ int main()
}
{
{
boost::unique_lock<boost::mutex> lock(mutex);
boost::unique_lock<boost::mutex> lock(g_mutex);
boost::thread* th2 = new boost::thread(&increment_count_2);
threads2.add_thread(th2);
g_threads2.add_thread(th2);
}
threads2.join_all();
g_threads2.join_all();
}
return boost::report_errors();
}
+4 -4
View File
@@ -8,21 +8,21 @@
#include <boost/thread/tss.hpp>
#include <cassert>
boost::thread_specific_ptr<int> value;
boost::thread_specific_ptr<int> g_value;
void increment()
{
int* p = value.get();
int* p = g_value.get();
++*p;
}
void thread_proc()
{
value.reset(new int(0)); // initialize the thread's storage
g_value.reset(new int(0)); // initialize the thread's storage
for (int i=0; i<10; ++i)
{
increment();
int* p = value.get();
int* p = g_value.get();
assert(*p == i+1);
(void)(p);
}
+8 -8
View File
@@ -12,18 +12,18 @@
#include <boost/thread/scoped_thread.hpp>
#include <boost/thread/with_lock_guard.hpp>
boost::mutex m; // protection for 'x' and 'std::cout'
int x;
boost::mutex g_mutex; // protection for 'g_x' and 'std::cout'
int g_x = 0;
#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700)
void print_x() {
++x;
std::cout << "x = " << x << std::endl;
++g_x;
std::cout << "x = " << g_x << std::endl;
}
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(m, print_x);
boost::with_lock_guard(g_mutex, print_x);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
}
}
@@ -31,10 +31,10 @@ void job() {
void job() {
for (int i = 0; i < 10; ++i) {
boost::with_lock_guard(
m,
g_mutex,
[]() {
++x;
std::cout << "x = " << x << std::endl;
++g_x;
std::cout << "x = " << g_x << std::endl;
}
);
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
+48 -46
View File
@@ -21,6 +21,7 @@
#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
#include <boost/thread/detail/string_trim.hpp>
#include <boost/thread/detail/string_to_unsigned.hpp>
#include <boost/core/no_exceptions_support.hpp>
#ifdef __GLIBC__
#include <sys/sysinfo.h>
@@ -185,7 +186,7 @@ namespace boost
// Unhandled exceptions still cause the application to terminate
// BOOST_CATCH(...)
// {
// throw;
// throw;
//
// std::terminate();
// }
@@ -212,12 +213,13 @@ namespace boost
interrupt_enabled=false;
#endif
}
~externally_launched_thread() {
BOOST_ASSERT(notify.empty());
notify.clear();
~externally_launched_thread()
{
BOOST_ASSERT(notify.empty());
notify.clear();
//#ifndef BOOST_NO_EXCEPTIONS
BOOST_ASSERT(async_states_.empty());
async_states_.clear();
BOOST_ASSERT(async_states_.empty());
async_states_.clear();
//#endif
}
void run()
@@ -354,7 +356,7 @@ namespace boost
}
else
{
return false;
return false;
}
}
@@ -373,8 +375,8 @@ namespace boost
}
if(!local_thread_info->done)
{
res=false;
return true;
res=false;
return true;
}
do_join=!local_thread_info->join_started;
@@ -437,31 +439,31 @@ namespace boost
namespace this_thread
{
namespace no_interruption_point
{
namespace hidden
namespace no_interruption_point
{
void BOOST_THREAD_DECL sleep_for_internal(const detail::platform_duration& ts)
{
if (ts > detail::platform_duration::zero())
namespace hidden
{
void BOOST_THREAD_DECL sleep_for_internal(const detail::platform_duration& ts)
{
// Use pthread_delay_np or nanosleep whenever possible here in the no_interruption_point
// namespace because they do not provide an interruption point.
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
# if defined(__IBMCPP__) || defined(_AIX)
BOOST_VERIFY(!pthread_delay_np(const_cast<timespec*>(&ts.getTs())));
# else
BOOST_VERIFY(!pthread_delay_np(&ts.getTs()));
# endif
# elif defined(BOOST_HAS_NANOSLEEP)
nanosleep(&ts.getTs(), 0);
# else
// This should never be reached due to BOOST_THREAD_SLEEP_FOR_IS_STEADY
# endif
if (ts > detail::platform_duration::zero())
{
// Use pthread_delay_np or nanosleep whenever possible here in the no_interruption_point
// namespace because they do not provide an interruption point.
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
# if defined(__IBMCPP__) || defined(_AIX)
BOOST_VERIFY(!pthread_delay_np(const_cast<timespec*>(&ts.getTs())));
# else
BOOST_VERIFY(!pthread_delay_np(&ts.getTs()));
# endif
# elif defined(BOOST_HAS_NANOSLEEP)
nanosleep(&ts.getTs(), 0);
# else
// This should never be reached due to BOOST_THREAD_SLEEP_FOR_IS_STEADY
# endif
}
}
}
}
}
}
void yield() BOOST_NOEXCEPT
{
@@ -515,7 +517,7 @@ namespace boost
unsigned thread::physical_concurrency() BOOST_NOEXCEPT
{
#ifdef __linux__
try {
BOOST_TRY {
using namespace std;
ifstream proc_cpuinfo ("/proc/cpuinfo");
@@ -570,9 +572,10 @@ namespace boost
// Fall back to hardware_concurrency() in case
// /proc/cpuinfo is formatted differently than we expect.
return cores.size() != 0 ? cores.size() : hardware_concurrency();
} catch(...) {
return hardware_concurrency();
} BOOST_CATCH(...) {
return hardware_concurrency();
}
BOOST_CATCH_END
#elif defined(__APPLE__)
int count;
size_t size=sizeof(count);
@@ -786,26 +789,25 @@ namespace boost
BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
{
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
}
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
}
}
//#ifndef BOOST_NO_EXCEPTIONS
namespace detail {
namespace detail
{
void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
{
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->make_ready_at_thread_exit(as);
}
detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
if(current_thread_data)
{
current_thread_data->make_ready_at_thread_exit(as);
}
}
}
//#endif
}
+1
View File
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <windows.h>
#include <boost/predef/platform.h>
#include <boost/core/no_exceptions_support.hpp>
#if BOOST_PLAT_WINDOWS_RUNTIME
#include <mutex>
+11 -8
View File
@@ -110,18 +110,18 @@ project
<toolset>msvc:<cxxflags>/wd6246
;
rule thread-run ( sources )
rule thread-run ( sources : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
[ run $(sources) ../build//boost_thread ]
[ run $(sources) ../build//boost_thread : : : $(reqs) ]
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
: : : : $(sources[1]:B)_lib ]
: : : $(reqs) : $(sources[1]:B)_lib ]
;
}
rule thread-test ( sources )
rule thread-test ( sources : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
@@ -136,14 +136,14 @@ rule thread-test ( sources )
;
}
rule thread-run2 ( sources : name )
rule thread-run2 ( sources : name : reqs * )
{
sources = $(sources) winrt_init.cpp ;
return
[ run $(sources) ../build//boost_thread : : :
[ run $(sources) ../build//boost_thread : : : $(reqs)
: $(name) ]
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
: : :
: : : $(reqs)
: $(name)_lib ]
;
}
@@ -362,7 +362,10 @@ rule generate_self_contained_header_tests
[ thread-run test_7571.cpp ]
[ thread-run test_9319.cpp ]
#[ thread-run test_9711.cpp ] This is an invalid use of ::then deferred.
[ thread-run test_9856.cpp ]
[ thread-run test_9856.cpp :
<toolset>gcc:<cxxflags>-fopenmp
<toolset>gcc:<linkflags>-fopenmp
]
[ thread-compile test_10963.cpp : : test_10963_c ]
[ thread-run test_10964.cpp ]
[ thread-test test_11053.cpp ]
+5 -1
View File
@@ -30,12 +30,16 @@ struct wait_for_flag
flag(flag_)
{}
check_flag(check_flag const& that):
flag(that.flag)
{}
bool operator()() const
{
return flag;
}
private:
void operator=(check_flag&);
check_flag& operator=(check_flag const&);
};
@@ -23,8 +23,8 @@
#include <boost/thread/locks.hpp>
#include <boost/core/lightweight_test.hpp>
boost::condition_variable* cv;
boost::mutex m;
boost::condition_variable* g_cv;
boost::mutex g_mutex;
typedef boost::unique_lock<boost::mutex> Lock;
bool f_ready = false;
@@ -32,33 +32,33 @@ bool g_ready = false;
void f()
{
Lock lk(m);
Lock lk(g_mutex);
f_ready = true;
cv->notify_one();
cv->wait(lk);
delete cv;
g_cv->notify_one();
g_cv->wait(lk);
delete g_cv;
}
void g()
{
Lock lk(m);
Lock lk(g_mutex);
g_ready = true;
cv->notify_one();
g_cv->notify_one();
while (!f_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
cv->notify_one();
g_cv->notify_one();
}
int main()
{
cv = new boost::condition_variable;
g_cv = new boost::condition_variable;
boost::thread th2(g);
Lock lk(m);
Lock lk(g_mutex);
while (!g_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
lk.unlock();
boost::thread th1(f);
@@ -60,7 +60,7 @@ bool threadIsWaiting()
#ifdef BOOST_THREAD_USES_DATETIME
boost::posix_time::milliseconds posix_wait_time(1000);
boost::posix_time::milliseconds posix_wait_time(2000);
template <typename F>
void test_posix_wait_function(F f)
@@ -68,12 +68,14 @@ void test_posix_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
lk.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
boost::posix_time::ptime t0 = boost::posix_time::microsec_clock::universal_time();
flag = true;
@@ -82,7 +84,7 @@ void test_posix_wait_function(F f)
t.join();
boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::universal_time();
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -131,7 +133,7 @@ void timed_wait_relative_with_pred()
#ifdef BOOST_THREAD_USES_CHRONO
boost::chrono::milliseconds chrono_wait_time(1000);
boost::chrono::milliseconds chrono_wait_time(2000);
template <typename F>
void test_chrono_wait_function(F f)
@@ -139,12 +141,14 @@ void test_chrono_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
lk.unlock();
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
boost::chrono::steady_clock::time_point t0 = boost::chrono::steady_clock::now();
flag = true;
@@ -153,7 +157,7 @@ void test_chrono_wait_function(F f)
t.join();
boost::chrono::steady_clock::time_point t1 = boost::chrono::steady_clock::now();
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -56,7 +56,7 @@ typedef boost::chrono::milliseconds milliseconds;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
BOOST_ATTRIBUTE_UNUSED const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
@@ -68,6 +68,8 @@ void f()
BOOST_ATTRIBUTE_UNUSED Clock::time_point t0 = Clock::now();
cv.wait_for(lk, milliseconds(250), Pred(test2));
BOOST_ATTRIBUTE_UNUSED Clock::time_point t1 = Clock::now();
(void)t0;
(void)t1;
if (runs == 0)
{
assert(t1 - t0 < max_diff);
@@ -82,6 +82,7 @@ void f()
Clock::time_point t = t0 + Clock::duration(250);
BOOST_ATTRIBUTE_UNUSED bool r = cv.wait_until(lk, t, Pred(test2));
Clock::time_point t1 = Clock::now();
(void)r;
if (runs == 0)
{
assert(t1 - t0 < max_diff);
@@ -23,8 +23,8 @@
#include <boost/thread/locks.hpp>
#include <boost/core/lightweight_test.hpp>
boost::condition_variable_any* cv;
boost::timed_mutex m;
boost::condition_variable_any* g_cv;
boost::timed_mutex g_mutex;
typedef boost::unique_lock<boost::timed_mutex> Lock;
bool f_ready = false;
@@ -32,33 +32,33 @@ bool g_ready = false;
void f()
{
Lock lk(m);
Lock lk(g_mutex);
f_ready = true;
cv->notify_one();
cv->wait(lk);
delete cv;
g_cv->notify_one();
g_cv->wait(lk);
delete g_cv;
}
void g()
{
Lock lk(m);
Lock lk(g_mutex);
g_ready = true;
cv->notify_one();
g_cv->notify_one();
while (!f_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
cv->notify_one();
g_cv->notify_one();
}
int main()
{
cv = new boost::condition_variable_any;
g_cv = new boost::condition_variable_any;
boost::thread th2(g);
Lock lk(m);
Lock lk(g_mutex);
while (!g_ready)
{
cv->wait(lk);
g_cv->wait(lk);
}
lk.unlock();
boost::thread th1(f);
@@ -60,7 +60,7 @@ bool threadIsWaiting()
#ifdef BOOST_THREAD_USES_DATETIME
boost::posix_time::milliseconds posix_wait_time(1000);
boost::posix_time::milliseconds posix_wait_time(2000);
template <typename F>
void test_posix_wait_function(F f)
@@ -68,12 +68,14 @@ void test_posix_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
lk.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
boost::posix_time::ptime t0 = boost::posix_time::microsec_clock::universal_time();
flag = true;
@@ -82,7 +84,7 @@ void test_posix_wait_function(F f)
t.join();
boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::universal_time();
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::posix_time::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -131,7 +133,7 @@ void timed_wait_relative_with_pred()
#ifdef BOOST_THREAD_USES_CHRONO
boost::chrono::milliseconds chrono_wait_time(1000);
boost::chrono::milliseconds chrono_wait_time(2000);
template <typename F>
void test_chrono_wait_function(F f)
@@ -139,12 +141,14 @@ void test_chrono_wait_function(F f)
flag = false;
waiting = false;
boost::thread t(f);
boost::unique_lock<boost::mutex> lk(mut);
while (!threadIsWaiting())
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
lk.unlock();
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
lk.lock();
}
boost::unique_lock<boost::mutex> lk(mut);
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
boost::chrono::steady_clock::time_point t0 = boost::chrono::steady_clock::now();
flag = true;
@@ -153,7 +157,7 @@ void test_chrono_wait_function(F f)
t.join();
boost::chrono::steady_clock::time_point t1 = boost::chrono::steady_clock::now();
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(250));
BOOST_TEST(t1 - t0 < boost::chrono::milliseconds(500));
}
//------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ int f0()
return 3;
}
int i = 0;
int g_i = 0;
int& f1()
{
boost::this_thread::sleep_for(ms(200));
return i;
return g_i;
}
void f2()
+8 -8
View File
@@ -109,12 +109,12 @@ int f0()
return 3;
}
int i = 0;
int g_i = 0;
int& f1()
{
boost::this_thread::sleep_for(ms(200));
return i;
return g_i;
}
void f2()
@@ -153,8 +153,8 @@ struct check_timer {
boost::chrono::nanoseconds delay;
Clock::time_point start;
check_timer(boost::chrono::nanoseconds delay)
: delay(delay)
, start(Clock::now())
: delay(delay)
, start(Clock::now())
{
}
~check_timer() {
@@ -490,7 +490,7 @@ int main()
check_timer timer(ms(500));
res = &f.get();
}
BOOST_TEST(res == &i);
BOOST_TEST(res == &g_i);
}
catch (std::exception& ex)
{
@@ -513,7 +513,7 @@ int main()
check_timer timer(ms(500));
res = &f.get();
}
BOOST_TEST(res == &i);
BOOST_TEST(res == &g_i);
}
catch (std::exception& ex)
{
@@ -536,7 +536,7 @@ int main()
check_timer timer(ms(500));
res = &f.get();
}
BOOST_TEST(res == &i);
BOOST_TEST(res == &g_i);
}
catch (std::exception& ex)
{
@@ -560,7 +560,7 @@ int main()
check_timer timer(ms(500));
res = &f.get();
}
BOOST_TEST(res == &i);
BOOST_TEST(res == &g_i);
}
catch (std::exception& ex)
{
+3 -3
View File
@@ -51,13 +51,13 @@ void func2(boost::promise<int> p)
p.set_exception(::make_exception_ptr(3));
}
int j = 0;
int g_j = 0;
void func3(boost::promise<int&> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
j = 5;
p.set_value(j);
g_j = 5;
p.set_value(g_j);
}
void func4(boost::promise<int&> p)
+3 -3
View File
@@ -61,13 +61,13 @@ void func2(boost::promise<int> p)
p.set_exception(::make_exception_ptr(3));
}
int j = 0;
int g_j = 0;
void func3(boost::promise<int&> p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
j = 5;
p.set_value(j);
g_j = 5;
p.set_value(g_j);
}
void func4(boost::promise<int&> p)
@@ -23,9 +23,6 @@
#include <boost/thread/future.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
int main()
{
{
@@ -23,8 +23,6 @@
#include <boost/thread/future.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
int main()
{
{
@@ -75,4 +73,3 @@ int main()
return boost::report_errors();
}
+9 -9
View File
@@ -56,13 +56,13 @@ void func1(boost::promise<int> p)
p.set_value(3);
}
int j = 0;
int g_j = 0;
void func3(boost::promise<int&> p)
{
boost::this_thread::sleep_for(ms(500));
j = 5;
p.set_value(j);
g_j = 5;
p.set_value(g_j);
}
void func5(boost::promise<void> p)
@@ -86,13 +86,13 @@ int main()
boost::thread(func1, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func1(boost::move(p));
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -109,13 +109,13 @@ int main()
boost::thread(func3, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func3(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -132,13 +132,13 @@ int main()
boost::thread(func5, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func5(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
+3 -3
View File
@@ -54,13 +54,13 @@ void func1(boost::promise<int> p)
p.set_value(3);
}
int j = 0;
int g_j = 0;
void func3(boost::promise<int&> p)
{
boost::this_thread::sleep_for(ms(500));
j = 5;
p.set_value(j);
g_j = 5;
p.set_value(g_j);
}
void func5(boost::promise<void> p)
+9 -9
View File
@@ -57,13 +57,13 @@ void func1(boost::promise<int> p)
p.set_value(3);
}
int j = 0;
int g_j = 0;
void func3(boost::promise<int&> p)
{
boost::this_thread::sleep_for(ms(500));
j = 5;
p.set_value(j);
g_j = 5;
p.set_value(g_j);
}
void func5(boost::promise<void> p)
@@ -87,13 +87,13 @@ int main()
boost::thread(func1, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func1(boost::move(p));
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -110,13 +110,13 @@ int main()
boost::thread(func3, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func3(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -133,13 +133,13 @@ int main()
boost::thread(func5, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func5(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -26,9 +26,6 @@
#include "../test_allocator.hpp"
#endif
boost::mutex m0;
boost::mutex m1;
int main()
{
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
@@ -26,8 +26,6 @@
#include "../test_allocator.hpp"
#endif
boost::mutex m;
int main()
{
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
@@ -148,4 +146,3 @@ int main()
return boost::report_errors();
}
@@ -24,22 +24,22 @@
#include <boost/core/lightweight_test.hpp>
#include <memory>
int i = 0;
int g_i = 0;
//void func(boost::promise<int&> p)
boost::promise<int&> p;
boost::promise<int&> g_p;
void func()
{
p.set_value_at_thread_exit(i);
i = 4;
g_p.set_value_at_thread_exit(g_i);
g_i = 4;
}
int main()
{
{
//boost::promise<int&> p;
boost::future<int&> f = p.get_future();
//boost::thread(func, boost::move(p)).detach();
//boost::promise<int&> g_p;
boost::future<int&> f = g_p.get_future();
//boost::thread(func, boost::move(g_p)).detach();
boost::thread(func).detach();
int r = f.get();
BOOST_TEST(r == 4);
@@ -25,27 +25,27 @@
#include <boost/thread/detail/memory.hpp>
#include <boost/thread/csbl/memory/unique_ptr.hpp>
boost::promise<boost::csbl::unique_ptr<int> > p;
boost::promise<boost::csbl::unique_ptr<int> > p2;
boost::promise<boost::csbl::unique_ptr<int> > g_p;
boost::promise<boost::csbl::unique_ptr<int> > g_p2;
void func()
{
boost::csbl::unique_ptr<int> uptr(new int(5));
p.set_value_at_thread_exit(boost::move(uptr));
g_p.set_value_at_thread_exit(boost::move(uptr));
}
void func2()
{
p2.set_value_at_thread_exit(boost::csbl::make_unique<int>(5));
g_p2.set_value_at_thread_exit(boost::csbl::make_unique<int>(5));
}
int main()
{
{
boost::future<boost::csbl::unique_ptr<int> > f = p.get_future();
boost::future<boost::csbl::unique_ptr<int> > f = g_p.get_future();
boost::thread(func).detach();
BOOST_TEST(*f.get() == 5);
}
{
boost::future<boost::csbl::unique_ptr<int> > f = p2.get_future();
boost::future<boost::csbl::unique_ptr<int> > f = g_p2.get_future();
boost::thread(func2).detach();
BOOST_TEST(*f.get() == 5);
}
@@ -24,25 +24,25 @@
#include <boost/core/lightweight_test.hpp>
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
void func(boost::promise<int> p)
void func(boost::promise<int> prom)
#else
boost::promise<int> p;
boost::promise<int> prom;
void func()
#endif
{
const int i = 5;
p.set_value_at_thread_exit(i);
prom.set_value_at_thread_exit(i);
}
int main()
{
{
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
boost::promise<int> p;
boost::future<int> f = p.get_future();
boost::thread(func, boost::move(p)).detach();
boost::promise<int> prom;
boost::future<int> f = prom.get_future();
boost::thread(func, boost::move(prom)).detach();
#else
boost::future<int> f = p.get_future();
boost::future<int> f = prom.get_future();
boost::thread(func).detach();
#endif
try
@@ -23,35 +23,35 @@
#include <boost/thread/future.hpp>
#include <boost/core/lightweight_test.hpp>
int i = 0;
int g_i = 0;
boost::promise<void> p;
boost::promise<void> g_p;
void func()
{
p.set_value_at_thread_exit();
i = 1;
g_p.set_value_at_thread_exit();
g_i = 1;
}
//void func2_mv(BOOST_THREAD_RV_REF(boost::promise<void>) p2)
void func2_mv(boost::promise<void> p2)
{
p2.set_value_at_thread_exit();
i = 2;
g_i = 2;
}
void func2(boost::promise<void> *p2)
{
p2->set_value_at_thread_exit();
i = 2;
g_i = 2;
}
int main()
{
try
{
boost::future<void> f = p.get_future();
boost::future<void> f = g_p.get_future();
boost::thread(func).detach();
f.get();
BOOST_TEST(i == 1);
BOOST_TEST(g_i == 1);
}
catch(std::exception& )
@@ -67,10 +67,10 @@ int main()
{
boost::promise<void> p2;
boost::future<void> f = p2.get_future();
p = boost::move(p2);
g_p = boost::move(p2);
boost::thread(func).detach();
f.get();
BOOST_TEST(i == 1);
BOOST_TEST(g_i == 1);
}
catch(std::exception& ex)
@@ -94,7 +94,7 @@ int main()
#endif
f.wait();
f.get();
BOOST_TEST(i == 2);
BOOST_TEST(g_i == 2);
}
catch(std::exception& ex)
{
@@ -23,9 +23,6 @@
#include <boost/thread/future.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
int main()
{
{
@@ -23,8 +23,6 @@
#include <boost/thread/future.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
int main()
{
{
@@ -75,4 +73,3 @@ int main()
return boost::report_errors();
}
@@ -86,13 +86,13 @@ int main()
boost::thread(func1, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func1(boost::move(p));
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -109,13 +109,13 @@ int main()
boost::thread(func3, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func3(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -132,13 +132,13 @@ int main()
boost::thread(func5, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_for(ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_for(ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func5(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_for(ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_for(ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -87,13 +87,13 @@ int main()
boost::thread(func1, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func1(boost::move(p));
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -110,13 +110,13 @@ int main()
boost::thread(func3, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func3(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
@@ -133,13 +133,13 @@ int main()
boost::thread(func5, boost::move(p)).detach();
#endif
BOOST_TEST(f.valid());
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(250)) , boost::future_status::timeout);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(100)) , boost::future_status::timeout);
BOOST_TEST(f.valid());
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
#else
func5(boost::move(p));
#endif
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(750)) , boost::future_status::ready);
BOOST_TEST_EQ(f.wait_until(Clock::now() + ms(2000)) , boost::future_status::ready);
BOOST_TEST(f.valid());
Clock::time_point t0 = Clock::now();
f.wait();
+22 -22
View File
@@ -332,28 +332,28 @@ int main()
}
#endif
#if ! defined BOOST_NO_CXX11_LAMBDAS
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::future<int> > v;
v.push_back(boost::move(f1));
v.push_back(boost::move(f2));
BOOST_TEST(v[0].valid());
BOOST_TEST(v[1].valid());
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_all(v.begin(), v.end());
BOOST_TEST(! v[0].valid());
BOOST_TEST(! v[1].valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::vector<boost::future<int> > > f)
{
boost::csbl::vector<boost::future<int> > v = f.get();
return v[0].get() + v[1].get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::future<int> > v;
v.push_back(boost::move(f1));
v.push_back(boost::move(f2));
BOOST_TEST(v[0].valid());
BOOST_TEST(v[1].valid());
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_all(v.begin(), v.end());
BOOST_TEST(! v[0].valid());
BOOST_TEST(! v[1].valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::vector<boost::future<int> > > f)
{
boost::csbl::vector<boost::future<int> > v = f.get();
return v[0].get() + v[1].get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
#endif
#endif
+18 -19
View File
@@ -36,7 +36,6 @@
int p1()
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
return 123;
}
@@ -44,9 +43,9 @@ int thr()
{
throw std::logic_error("123");
}
int p2()
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
return 321;
}
@@ -275,23 +274,23 @@ int main()
}
#endif
#if ! defined BOOST_NO_CXX11_LAMBDAS
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_all(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
BOOST_TEST(! f2.valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::tuple<boost::future<int>, boost::future<int> > > f)
{
boost::csbl::tuple<boost::future<int>,boost::future<int> > v = f.get();
return boost::csbl::get<0>(v).get()+boost::csbl::get<1>(v).get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_all(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
BOOST_TEST(! f2.valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::tuple<boost::future<int>, boost::future<int> > > f)
{
boost::csbl::tuple<boost::future<int>,boost::future<int> > v = f.get();
return boost::csbl::get<0>(v).get()+boost::csbl::get<1>(v).get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
#endif
#endif
+37 -26
View File
@@ -28,6 +28,7 @@
#define BOOST_THREAD_VERSION 4
#include <boost/thread/future.hpp>
#include <boost/thread/barrier.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
@@ -44,9 +45,16 @@ int thr()
{
throw std::logic_error("123");
}
int p2()
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
return 321;
}
int p3(boost::barrier* bar = nullptr)
{
if (bar)
bar->count_down_and_wait();
return 321;
}
@@ -217,9 +225,10 @@ int main()
BOOST_TEST(res[1].get() == 321);
}
{ // async future copy-constructible
boost::barrier bar(2u);
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
boost::future<int> f2 = boost::async(boost::launch::async, &p3, &bar);
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::future<int> > v;
v.push_back(boost::move(f1));
@@ -236,12 +245,14 @@ int main()
BOOST_TEST(res[0].get() == 123);
BOOST_TEST(res[1].valid());
BOOST_TEST(! res[1].is_ready());
bar.count_down_and_wait();
BOOST_TEST(res[1].get() == 321);
}
{ // async shared_future copy-constructible
boost::barrier bar(2u);
boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
BOOST_TEST(f1.valid());
boost::shared_future<int> f2 = boost::async(boost::launch::async, &p2).share();
boost::shared_future<int> f2 = boost::async(boost::launch::async, &p3, &bar).share();
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::shared_future<int> > v;
v.push_back(f1);
@@ -260,6 +271,7 @@ int main()
BOOST_TEST(res[0].get() == 123);
BOOST_TEST(res[1].valid());
BOOST_TEST(! res[1].is_ready());
bar.count_down_and_wait();
BOOST_TEST(res[1].get() == 321);
}
{ // async future copy-constructible
@@ -333,31 +345,30 @@ int main()
}
#endif
#if ! defined BOOST_NO_CXX11_LAMBDAS
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::future<int> > v;
v.push_back(boost::move(f1));
v.push_back(boost::move(f2));
BOOST_TEST(v[0].valid());
BOOST_TEST(v[1].valid());
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_any(v.begin(), v.end());
BOOST_TEST(! v[0].valid());
BOOST_TEST(! v[1].valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::vector<boost::future<int> > > f)
{
boost::csbl::vector<boost::future<int> > v = f.get();
return v[0].get() + v[1].get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::csbl::vector<boost::future<int> > v;
v.push_back(boost::move(f1));
v.push_back(boost::move(f2));
BOOST_TEST(v[0].valid());
BOOST_TEST(v[1].valid());
boost::future<boost::csbl::vector<boost::future<int> > > all = boost::when_any(v.begin(), v.end());
BOOST_TEST(! v[0].valid());
BOOST_TEST(! v[1].valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::vector<boost::future<int> > > f)
{
boost::csbl::vector<boost::future<int> > v = f.get();
return v[0].get() + v[1].get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
#endif
#endif
return boost::report_errors();
}
+36 -22
View File
@@ -26,6 +26,7 @@
#define BOOST_THREAD_VERSION 4
#include <boost/thread/future.hpp>
#include <boost/thread/barrier.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
@@ -42,9 +43,16 @@ int thr()
{
throw std::logic_error("123");
}
int p2()
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
return 321;
}
int p3(boost::barrier* bar = nullptr)
{
if (bar)
bar->count_down_and_wait();
return 321;
}
@@ -180,9 +188,10 @@ int main()
BOOST_TEST(boost::csbl::get<1>(res).get() == 321);
}
{ // async future copy-constructible
boost::barrier bar(2u);
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
boost::future<int> f2 = boost::async(boost::launch::async, &p3, &bar);
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
@@ -192,12 +201,14 @@ int main()
BOOST_TEST(boost::csbl::get<0>(res).valid());
BOOST_TEST(boost::csbl::get<0>(res).is_ready() || boost::csbl::get<1>(res).is_ready());
BOOST_TEST(boost::csbl::get<0>(res).get() == 123);
bar.count_down_and_wait();
BOOST_TEST(boost::csbl::get<1>(res).get() == 321);
}
{ // async shared_future copy-constructible
boost::barrier bar(2u);
boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
BOOST_TEST(f1.valid());
boost::shared_future<int> f2 = boost::async(boost::launch::async, &p2).share();
boost::shared_future<int> f2 = boost::async(boost::launch::async, &p3, &bar).share();
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::shared_future<int>,boost::shared_future<int> > > all = boost::when_any(f1, f2);
BOOST_TEST(f1.valid());
@@ -208,6 +219,7 @@ int main()
BOOST_TEST(boost::csbl::get<1>(res).valid());
BOOST_TEST(boost::csbl::get<0>(res).is_ready() || boost::csbl::get<1>(res).is_ready());
BOOST_TEST(boost::csbl::get<0>(res).get() == 123);
bar.count_down_and_wait();
BOOST_TEST(boost::csbl::get<1>(res).get() == 321);
}
{ // async future copy-constructible
@@ -251,8 +263,9 @@ int main()
}
// fixme darwin-4.8.0_11 terminate called without an active exception
{ // deferred future copy-constructible
boost::barrier bar(2u);
boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
boost::future<int> f2 = boost::async(boost::launch::async, &p3, &bar);
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
BOOST_TEST(! f2.valid());
@@ -262,7 +275,8 @@ int main()
BOOST_TEST(boost::csbl::get<0>(res).is_ready());
BOOST_TEST(boost::csbl::get<0>(res).get() == 123);
BOOST_TEST(boost::csbl::get<1>(res).valid());
//BOOST_TEST(! boost::csbl::get<1>(res).is_ready());
BOOST_TEST(! boost::csbl::get<1>(res).is_ready());
bar.count_down_and_wait();
BOOST_TEST(boost::csbl::get<1>(res).get() == 321);
}
// fixme darwin-4.8.0_11 terminate called without an active exception
@@ -298,23 +312,23 @@ int main()
}
#endif
#if ! defined BOOST_NO_CXX11_LAMBDAS
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
BOOST_TEST(! f2.valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::tuple<boost::future<int>, boost::future<int> > > f)
{
boost::csbl::tuple<boost::future<int>,boost::future<int> > v = f.get();
return boost::csbl::get<0>(v).get()+boost::csbl::get<1>(v).get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
{ // async futures copy-constructible then()
boost::future<int> f1 = boost::async(boost::launch::async, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = boost::async(boost::launch::async, &p2);
BOOST_TEST(f2.valid());
boost::future<boost::csbl::tuple<boost::future<int>,boost::future<int> > > all = boost::when_any(boost::move(f1), boost::move(f2));
BOOST_TEST(! f1.valid());
BOOST_TEST(! f2.valid());
BOOST_TEST(all.valid());
boost::future<int> sum = all.then([](boost::future<boost::csbl::tuple<boost::future<int>, boost::future<int> > > f)
{
boost::csbl::tuple<boost::future<int>,boost::future<int> > v = f.get();
return boost::csbl::get<0>(v).get()+boost::csbl::get<1>(v).get();
});
BOOST_TEST(sum.valid());
BOOST_TEST(sum.get() == 444);
}
#endif
#endif
@@ -30,50 +30,50 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#ifdef BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
m.lock();
boost::lock_guard<boost::mutex> lg(m, boost::adopt_lock);
t1 = Clock::now();
g_mutex.lock();
boost::lock_guard<boost::mutex> lg(g_mutex, boost::adopt_lock);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
m.lock();
boost::lock_guard<boost::mutex> lg(m, boost::adopt_lock);
//t1 = Clock::now();
g_mutex.lock();
boost::lock_guard<boost::mutex> lg(g_mutex, boost::adopt_lock);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#ifdef BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -22,16 +22,15 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
boost::lock_guard<boost::mutex> lk0(m0);
boost::lock_guard<boost::mutex> lk1(m1);
boost::lock_guard<boost::mutex> lk0(g_mutex0);
boost::lock_guard<boost::mutex> lk1(g_mutex1);
lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -23,13 +23,13 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
int main()
{
boost::lock_guard<boost::mutex> lk0(m0);
boost::lock_guard<boost::mutex> lk0(g_mutex0);
boost::lock_guard<boost::mutex> lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -30,49 +30,49 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#ifdef BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
boost::lock_guard<boost::mutex> lg(m);
t1 = Clock::now();
boost::lock_guard<boost::mutex> lg(g_mutex);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
boost::lock_guard<boost::mutex> lg(m);
//t1 = Clock::now();
boost::lock_guard<boost::mutex> lg(g_mutex);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#ifdef BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -13,9 +13,9 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
boost::mutex g_mutex;
void fail()
{
boost::lock_guard<boost::mutex> lk(m, boost::adopt_lock);
boost::lock_guard<boost::mutex> lk(g_mutex, boost::adopt_lock);
}
@@ -13,10 +13,10 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
boost::mutex g_mutex;
void pass()
{
m.lock();
boost::lock_guard<boost::mutex> lk(m, boost::adopt_lock);
g_mutex.lock();
boost::lock_guard<boost::mutex> lk(g_mutex, boost::adopt_lock);
}
@@ -13,10 +13,10 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
boost::mutex g_mutex;
void fail()
{
boost::lock_guard<boost::mutex> lk0(m);
boost::lock_guard<boost::mutex> lk1(m);
boost::lock_guard<boost::mutex> lk0(g_mutex);
boost::lock_guard<boost::mutex> lk1(g_mutex);
}
@@ -13,12 +13,12 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
boost::mutex g_mutex;
void pass()
{
{
boost::lock_guard<boost::mutex> lk0(m);
boost::lock_guard<boost::mutex> lk0(g_mutex);
}
boost::lock_guard<boost::mutex> lk1(m);
boost::lock_guard<boost::mutex> lk1(g_mutex);
}
@@ -32,10 +32,10 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD
@@ -44,22 +44,22 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#ifdef BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
m.lock();
auto&& lg = boost::make_lock_guard(m, boost::adopt_lock); (void)lg;
g_mutex.lock();
auto&& lg = boost::make_lock_guard(g_mutex, boost::adopt_lock); (void)lg;
t1 = Clock::now();
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
m.lock();
auto&& lg = boost::make_lock_guard(m, boost::adopt_lock); (void)lg;
//t1 = Clock::now();
g_mutex.lock();
auto&& lg = boost::make_lock_guard(g_mutex, boost::adopt_lock); (void)lg;
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
@@ -68,19 +68,19 @@ void f()
int main()
{
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD
m.lock();
g_mutex.lock();
boost::thread t(f);
#ifdef BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -32,11 +32,11 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD && defined BOOST_THREAD_USES_CHRONO
@@ -44,10 +44,10 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
t0 = Clock::now();
g_t0 = Clock::now();
{
const auto&& lg = boost::make_lock_guard(m); (void)lg;
t1 = Clock::now();
const auto&& lg = boost::make_lock_guard(g_mutex); (void)lg;
g_t1 = Clock::now();
}
}
#endif
@@ -57,16 +57,16 @@ int main()
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD && defined BOOST_THREAD_USES_CHRONO
{
m.lock();
g_mutex.lock();
boost::thread t(f);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -14,18 +14,17 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
boost::unique_lock<boost::mutex> lk0(m0);
boost::unique_lock<boost::mutex> lk1(m1);
boost::unique_lock<boost::mutex> lk0(g_mutex0);
boost::unique_lock<boost::mutex> lk1(g_mutex1);
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > nlk0(lk0);
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > nlk1(lk1);
lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -15,14 +15,13 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
int main()
{
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > lk0(m0);
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > lk0(g_mutex0);
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -22,32 +22,32 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#ifdef BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
boost::unique_lock<boost::mutex> lg(m);
g_t0 = Clock::now();
boost::unique_lock<boost::mutex> lg(g_mutex);
{
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > nlg(lg);
t1 = Clock::now();
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
boost::unique_lock<boost::mutex> lg(m);
//time_point g_t0 = Clock::now();
//time_point g_t1;
boost::unique_lock<boost::mutex> lg(g_mutex);
{
boost::nested_strict_lock<boost::unique_lock<boost::mutex> > nlg(lg);
//t1 = Clock::now();
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
@@ -55,19 +55,19 @@ void f()
int main()
{
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#ifdef BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -24,11 +24,11 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK && defined BOOST_THREAD_USES_CHRONO
@@ -36,11 +36,11 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
t0 = Clock::now();
boost::unique_lock<boost::mutex> lg(m);
g_t0 = Clock::now();
boost::unique_lock<boost::mutex> lg(g_mutex);
{
const auto&& nlg = boost::make_nested_strict_lock(lg); (void)nlg;
t1 = Clock::now();
g_t1 = Clock::now();
}
}
#endif
@@ -50,16 +50,16 @@ int main()
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK && defined BOOST_THREAD_USES_CHRONO
{
m.lock();
g_mutex.lock();
boost::thread t(f);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -25,8 +25,8 @@ int main()
boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lk1);
lg1 = lg0;
(void)lg1;
}
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -15,9 +15,6 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_types.hpp>
boost::mutex m0;
boost::mutex m1;
int main()
{
boost::mutex m0;
@@ -25,8 +22,8 @@ int main()
{
boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lg0);
(void)lg1;
}
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -22,15 +22,15 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m0;
boost::shared_mutex m1;
boost::shared_mutex g_mutex0;
boost::shared_mutex g_mutex1;
int main()
{
boost::shared_lock<boost::shared_mutex> lk0(m0);
boost::shared_lock<boost::shared_mutex> lk1(m1);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex1);
lk1 = lk0;
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
@@ -23,18 +23,17 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m0;
boost::shared_mutex m1;
boost::shared_mutex g_mutex0;
boost::shared_mutex g_mutex1;
int main()
{
boost::shared_lock<boost::shared_mutex> lk0(m0);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock<boost::shared_mutex> lk1 = lk0;
BOOST_TEST(lk1.mutex() == &m1);
BOOST_TEST(lk1.mutex() == &g_mutex1);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
#include "../../../../../remove_error_code_unused_warning.hpp"
@@ -26,59 +26,59 @@
#include <boost/chrono/chrono_io.hpp>
#include "../../../../../timming.hpp"
boost::shared_mutex m;
boost::shared_mutex g_mutex;
typedef boost::chrono::high_resolution_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f1()
{
t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(m, ms(750));
g_t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(g_mutex, ms(750));
BOOST_TEST(lk.owns_lock() == true);
t1 = Clock::now();
g_t1 = Clock::now();
}
void f2()
{
t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(m, ms(250));
g_t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(g_mutex, ms(250));
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0 - ms(250);
g_t1 = Clock::now();
ns d = g_t1 - g_t0 - ms(250);
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
int main()
{
{
m.lock();
g_mutex.lock();
boost::thread t(f1);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
BOOST_THREAD_TEST_IT(d_ns, ns(max_diff));
}
{
m.lock();
g_mutex.lock();
boost::thread t(f2);
boost::this_thread::sleep_for(ms(750));
m.unlock();
g_mutex.unlock();
t.join();
}
@@ -23,60 +23,56 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m0;
boost::shared_mutex m1;
boost::shared_mutex g_mutex0;
boost::shared_mutex g_mutex1;
int main()
{
{
boost::shared_lock<boost::shared_mutex> lk0(m0);
boost::shared_lock<boost::shared_mutex> lk1(m1);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex1);
lk1 = boost::move(lk0);
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk1;
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(m0));
BOOST_TEST(lk1.mutex() == &m0);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(g_mutex0));
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
}
{
boost::unique_lock<boost::shared_mutex> lk0(m0);
boost::shared_lock<boost::shared_mutex> lk1(m1);
boost::unique_lock<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex1);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::move(lk0)));
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk1;
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::unique_lock<boost::shared_mutex>(m0)));
BOOST_TEST(lk1.mutex() == &m0);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::unique_lock<boost::shared_mutex>(g_mutex0)));
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
}
{
boost::upgrade_lock<boost::shared_mutex> lk0(m0);
boost::shared_lock<boost::shared_mutex> lk1(m1);
boost::upgrade_lock<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex1);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::move(lk0)));
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk1;
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::upgrade_lock<boost::shared_mutex>(m0)));
BOOST_TEST(lk1.mutex() == &m0);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::upgrade_lock<boost::shared_mutex>(g_mutex0)));
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
}
return boost::report_errors();
}
@@ -23,25 +23,23 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
{
boost::shared_lock<boost::shared_mutex> lk0(m);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(m))));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
boost::shared_lock<boost::shared_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(g_mutex))));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
}
return boost::report_errors();
}
@@ -23,43 +23,40 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
{
boost::unique_lock<boost::shared_mutex> lk0(m);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::unique_lock<boost::shared_mutex> lk0(g_mutex);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk( (boost::unique_lock<boost::shared_mutex>(m)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
boost::shared_lock<boost::shared_mutex> lk( (boost::unique_lock<boost::shared_mutex>(g_mutex)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
}
{
boost::unique_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::unique_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::unique_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
lk0.release();
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == 0);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::unique_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
lk0.release();
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == 0);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
return boost::report_errors();
}
@@ -23,42 +23,40 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
{
boost::upgrade_lock<boost::shared_mutex> lk0(m);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::upgrade_lock<boost::shared_mutex> lk0(g_mutex);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk( (boost::upgrade_lock<boost::shared_mutex>(m)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == true);
boost::shared_lock<boost::shared_mutex> lk( (boost::upgrade_lock<boost::shared_mutex>(g_mutex)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
}
{
boost::upgrade_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::upgrade_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::upgrade_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
lk0.release();
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == 0);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
boost::upgrade_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
lk0.release();
boost::shared_lock<boost::shared_mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == 0);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
return boost::report_errors();
}
@@ -24,7 +24,7 @@
#include <boost/core/lightweight_test.hpp>
#include "../../../../../timming.hpp"
boost::shared_mutex m;
boost::shared_mutex g_mutex;
#if defined BOOST_THREAD_USES_CHRONO
typedef boost::chrono::high_resolution_clock Clock;
@@ -32,8 +32,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -42,26 +42,26 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
boost::shared_lock<boost::shared_mutex> ul(m);
t1 = Clock::now();
boost::shared_lock<boost::shared_mutex> ul(g_mutex);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
boost::shared_lock<boost::shared_mutex> ul(m);
//t1 = Clock::now();
boost::shared_lock<boost::shared_mutex> ul(g_mutex);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -69,12 +69,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -25,59 +25,59 @@
#include <boost/core/lightweight_test.hpp>
#include "../../../../../timming.hpp"
boost::shared_mutex m;
boost::shared_mutex g_mutex;
typedef boost::chrono::high_resolution_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f1()
{
t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(m, Clock::now() + ms(750));
g_t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(g_mutex, Clock::now() + ms(750));
BOOST_TEST(lk.owns_lock() == true);
t1 = Clock::now();
g_t1 = Clock::now();
}
void f2()
{
t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(m, Clock::now() + ms(250));
g_t0 = Clock::now();
boost::shared_lock<boost::shared_mutex> lk(g_mutex, Clock::now() + ms(250));
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0 - ms(250);
g_t1 = Clock::now();
ns d = g_t1 - g_t0 - ms(250);
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
int main()
{
{
m.lock();
g_mutex.lock();
boost::thread t(f1);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
BOOST_THREAD_TEST_IT(d_ns, ns(max_diff));
}
{
m.lock();
g_mutex.lock();
boost::thread t(f2);
boost::this_thread::sleep_for(ms(750));
m.unlock();
g_mutex.unlock();
t.join();
}
@@ -24,7 +24,7 @@
#include <boost/core/lightweight_test.hpp>
#include "../../../../../timming.hpp"
boost::shared_mutex m;
boost::shared_mutex g_mutex;
#if defined BOOST_THREAD_USES_CHRONO
typedef boost::chrono::high_resolution_clock Clock;
@@ -32,8 +32,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -42,55 +42,55 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
}
for (;;)
{
boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
if (lk.owns_lock()) {
t1 = Clock::now();
g_t1 = Clock::now();
break;
}
}
#else
// time_point t0 = Clock::now();
// time_point g_t0 = Clock::now();
// {
// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
// boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
// {
// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
// boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
// {
// boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
// boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
for (;;)
{
boost::shared_lock<boost::shared_mutex> lk(m, boost::try_to_lock);
boost::shared_lock<boost::shared_mutex> lk(g_mutex, boost::try_to_lock);
if (lk.owns_lock()) break;
}
//time_point t1 = Clock::now();
//ns d = t1 - t0 - ms(250);
//time_point g_t1 = Clock::now();
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -98,12 +98,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -25,7 +25,7 @@
#include <iostream>
#include "../../../../../timming.hpp"
boost::shared_mutex m;
boost::shared_mutex g_mutex;
#if defined BOOST_THREAD_USES_CHRONO
typedef boost::chrono::high_resolution_clock Clock;
@@ -33,8 +33,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -43,10 +43,10 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
boost::shared_lock < boost::shared_mutex > lk(m, boost::defer_lock);
t0 = Clock::now();
boost::shared_lock < boost::shared_mutex > lk(g_mutex, boost::defer_lock);
g_t0 = Clock::now();
lk.lock();
t1 = Clock::now();
g_t1 = Clock::now();
BOOST_TEST(lk.owns_lock() == true);
try
{
@@ -69,12 +69,12 @@ void f()
BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
}
#else
boost::shared_lock < boost::shared_mutex > lk(m, boost::defer_lock);
//time_point t0 = Clock::now();
boost::shared_lock < boost::shared_mutex > lk(g_mutex, boost::defer_lock);
//time_point g_t0 = Clock::now();
lk.lock();
//time_point t1 = Clock::now();
//time_point g_t1 = Clock::now();
BOOST_TEST(lk.owns_lock() == true);
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
try
{
@@ -101,7 +101,7 @@ void f()
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -109,12 +109,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -41,11 +41,11 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
boost::shared_lock<shared_mutex> lk(g_mutex, boost::defer_lock);
BOOST_TEST(lk.try_lock_for(ms(5)) == true);
BOOST_TEST(try_lock_for_called == true);
BOOST_TEST(lk.owns_lock() == true);
@@ -37,11 +37,11 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
boost::shared_lock<shared_mutex> lk(g_mutex, boost::defer_lock);
BOOST_TEST(lk.try_lock() == true);
BOOST_TEST(try_lock_called == true);
BOOST_TEST(lk.owns_lock() == true);
@@ -22,6 +22,11 @@
#include <boost/thread/lock_types.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
typedef boost::chrono::steady_clock clock_type;
clock_type::time_point g_abs_timeout;
bool try_lock_until_called = false;
@@ -30,8 +35,7 @@ struct shared_mutex
template <class Clock, class Duration>
bool try_lock_shared_until(const boost::chrono::time_point<Clock, Duration>& abs_time)
{
typedef boost::chrono::milliseconds ms;
BOOST_TEST(Clock::now() - abs_time < ms(5));
BOOST_TEST(abs_time == g_abs_timeout);
try_lock_until_called = !try_lock_until_called;
return try_lock_until_called;
}
@@ -40,18 +44,19 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
typedef boost::chrono::steady_clock Clock;
boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
BOOST_TEST(lk.try_lock_until(Clock::now()) == true);
boost::shared_lock<shared_mutex> lk(g_mutex, boost::defer_lock);
g_abs_timeout = clock_type::now();
BOOST_TEST(lk.try_lock_until((clock_type::time_point)g_abs_timeout) == true);
BOOST_TEST(try_lock_until_called == true);
BOOST_TEST(lk.owns_lock() == true);
try
{
lk.try_lock_until(Clock::now());
g_abs_timeout = clock_type::now();
lk.try_lock_until((clock_type::time_point)g_abs_timeout);
BOOST_TEST(false);
}
catch (boost::system::system_error& e)
@@ -59,13 +64,15 @@ int main()
BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
}
lk.unlock();
BOOST_TEST(lk.try_lock_until(Clock::now()) == false);
g_abs_timeout = clock_type::now();
BOOST_TEST(lk.try_lock_until((clock_type::time_point)g_abs_timeout) == false);
BOOST_TEST(try_lock_until_called == false);
BOOST_TEST(lk.owns_lock() == false);
lk.release();
try
{
lk.try_lock_until(Clock::now());
g_abs_timeout = clock_type::now();
lk.try_lock_until((clock_type::time_point)g_abs_timeout);
BOOST_TEST(false);
}
catch (boost::system::system_error& e)
@@ -36,11 +36,11 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk(m);
boost::shared_lock<shared_mutex> lk(g_mutex);
lk.unlock();
BOOST_TEST(unlock_called == true);
BOOST_TEST(lk.owns_lock() == false);
@@ -31,16 +31,16 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk1(m);
boost::shared_lock<shared_mutex> lk1(g_mutex);
boost::shared_lock<shared_mutex> lk2;
lk1.swap(lk2);
BOOST_TEST(lk1.mutex() == 0);
BOOST_TEST(lk1.owns_lock() == false);
BOOST_TEST(lk2.mutex() == &m);
BOOST_TEST(lk2.mutex() == &g_mutex);
BOOST_TEST(lk2.owns_lock() == true);
return boost::report_errors();
@@ -30,16 +30,16 @@ struct shared_mutex
}
};
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk1(m);
boost::shared_lock<shared_mutex> lk1(g_mutex);
boost::shared_lock<shared_mutex> lk2;
swap(lk1, lk2);
BOOST_TEST(lk1.mutex() == 0);
BOOST_TEST(lk1.owns_lock() == false);
BOOST_TEST(lk2.mutex() == &m);
BOOST_TEST(lk2.mutex() == &g_mutex);
BOOST_TEST(lk2.owns_lock() == true);
return boost::report_errors();
@@ -38,16 +38,16 @@ struct shared_mutex
int shared_mutex::lock_count = 0;
int shared_mutex::unlock_count = 0;
shared_mutex m;
shared_mutex g_mutex;
int main()
{
boost::shared_lock<shared_mutex> lk(m);
BOOST_TEST(lk.mutex() == &m);
boost::shared_lock<shared_mutex> lk(g_mutex);
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(shared_mutex::lock_count == 1);
BOOST_TEST(shared_mutex::unlock_count == 0);
BOOST_TEST(lk.release() == &m);
BOOST_TEST(lk.release() == &g_mutex);
BOOST_TEST(lk.mutex() == 0);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(shared_mutex::lock_count == 1);
@@ -22,16 +22,16 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
boost::shared_lock<boost::shared_mutex> lk0;
BOOST_TEST(lk0.mutex() == 0);
boost::shared_lock<boost::shared_mutex> lk1(m);
BOOST_TEST(lk1.mutex() == &m);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex);
BOOST_TEST(lk1.mutex() == &g_mutex);
lk1.unlock();
BOOST_TEST(lk1.mutex() == &m);
BOOST_TEST(lk1.mutex() == &g_mutex);
return boost::report_errors();
}
@@ -22,13 +22,13 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
boost::shared_lock < boost::shared_mutex > lk0;
BOOST_TEST(bool(lk0) == false);
boost::shared_lock < boost::shared_mutex > lk1(m);
boost::shared_lock < boost::shared_mutex > lk1(g_mutex);
BOOST_TEST(bool(lk1) == true);
lk1.unlock();
BOOST_TEST(bool(lk1) == false);
@@ -22,13 +22,13 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
boost::shared_lock<boost::shared_mutex> lk0;
BOOST_TEST(lk0.owns_lock() == false);
boost::shared_lock<boost::shared_mutex> lk1(m);
boost::shared_lock<boost::shared_mutex> lk1(g_mutex);
BOOST_TEST(lk1.owns_lock() == true);
lk1.unlock();
BOOST_TEST(lk1.owns_lock() == false);
@@ -30,40 +30,40 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
boost::shared_mutex m;
boost::shared_mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
m.lock_shared();
boost::shared_lock_guard<boost::shared_mutex> lg(m, boost::adopt_lock);
t1 = Clock::now();
g_mutex.lock_shared();
boost::shared_lock_guard<boost::shared_mutex> lg(g_mutex, boost::adopt_lock);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
m.lock_shared();
boost::shared_lock_guard<boost::shared_mutex> lg(m, boost::adopt_lock);
//t1 = Clock::now();
g_mutex.lock_shared();
boost::shared_lock_guard<boost::shared_mutex> lg(g_mutex, boost::adopt_lock);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -71,12 +71,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -22,16 +22,15 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m0;
boost::shared_mutex m1;
boost::shared_mutex g_mutex0;
boost::shared_mutex g_mutex1;
int main()
{
boost::shared_lock_guard<boost::shared_mutex> lk0(m0);
boost::shared_lock_guard<boost::shared_mutex> lk1(m1);
boost::shared_lock_guard<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock_guard<boost::shared_mutex> lk1(g_mutex1);
lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -23,14 +23,13 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m0;
boost::shared_mutex m1;
boost::shared_mutex g_mutex0;
int main()
{
boost::shared_lock_guard<boost::shared_mutex> lk0(m0);
boost::shared_lock_guard<boost::shared_mutex> lk0(g_mutex0);
boost::shared_lock_guard<boost::shared_mutex> lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -31,38 +31,38 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
boost::shared_mutex m;
boost::shared_mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
boost::shared_lock_guard<boost::shared_mutex> lg(m);
t1 = Clock::now();
boost::shared_lock_guard<boost::shared_mutex> lg(g_mutex);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
boost::shared_lock_guard<boost::shared_mutex> lg(m);
//t1 = Clock::now();
boost::shared_lock_guard<boost::shared_mutex> lg(g_mutex);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -70,12 +70,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -13,16 +13,15 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
boost::strict_lock<boost::mutex> lk0(m0);
boost::strict_lock<boost::mutex> lk1(m1);
boost::strict_lock<boost::mutex> lk0(g_mutex0);
boost::strict_lock<boost::mutex> lk1(g_mutex1);
lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -14,13 +14,13 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
int main()
{
boost::strict_lock<boost::mutex> lk0(m0);
boost::strict_lock<boost::mutex> lk0(g_mutex0);
boost::strict_lock<boost::mutex> lk1 = lk0;
(void)lk1;
}
#include "../../../../remove_error_code_unused_warning.hpp"
@@ -21,49 +21,49 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#ifdef BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
boost::strict_lock<boost::mutex> lg(m);
t1 = Clock::now();
boost::strict_lock<boost::mutex> lg(g_mutex);
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
boost::strict_lock<boost::mutex> lg(m);
//t1 = Clock::now();
boost::strict_lock<boost::mutex> lg(g_mutex);
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#ifdef BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -23,11 +23,11 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#endif
boost::mutex m;
boost::mutex g_mutex;
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_STRICT_LOCK && defined BOOST_THREAD_USES_CHRONO
@@ -35,12 +35,12 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
t0 = Clock::now();
g_t0 = Clock::now();
{
const auto&& lg = boost::make_strict_lock(m); (void)lg;
t1 = Clock::now();
const auto&& lg = boost::make_strict_lock(g_mutex); (void)lg;
g_t1 = Clock::now();
}
ns d = t1 - t0 - ms(250);
ns d = g_t1 - g_t0 - ms(250);
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
#endif
@@ -50,16 +50,16 @@ int main()
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_MAKE_STRICT_LOCK && defined BOOST_THREAD_USES_CHRONO
{
m.lock();
g_mutex.lock();
boost::thread t(f);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -22,15 +22,15 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
boost::unique_lock<boost::mutex> lk0(m0);
boost::unique_lock<boost::mutex> lk1(m1);
boost::unique_lock<boost::mutex> lk0(g_mutex0);
boost::unique_lock<boost::mutex> lk1(g_mutex1);
lk1 = lk0;
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
@@ -38,4 +38,3 @@ int main()
}
#include "../../../../../remove_error_code_unused_warning.hpp"
@@ -23,18 +23,17 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
boost::unique_lock<boost::mutex> lk0(m0);
boost::unique_lock<boost::mutex> lk0(g_mutex0);
boost::unique_lock<boost::mutex> lk1 = lk0;
BOOST_TEST(lk1.mutex() == &m1);
BOOST_TEST(lk1.mutex() == &g_mutex1);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
#include "../../../../../remove_error_code_unused_warning.hpp"
@@ -30,59 +30,59 @@
#if defined BOOST_THREAD_USES_CHRONO
boost::timed_mutex m;
boost::timed_mutex g_mutex;
typedef boost::chrono::high_resolution_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f1()
{
t0 = Clock::now();
boost::unique_lock<boost::timed_mutex> lk(m, ms(750));
g_t0 = Clock::now();
boost::unique_lock<boost::timed_mutex> lk(g_mutex, ms(750));
BOOST_TEST(lk.owns_lock() == true);
t1 = Clock::now();
g_t1 = Clock::now();
}
void f2()
{
t0 = Clock::now();
boost::unique_lock<boost::timed_mutex> lk(m, ms(250));
g_t0 = Clock::now();
boost::unique_lock<boost::timed_mutex> lk(g_mutex, ms(250));
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0 - ms(250);
g_t1 = Clock::now();
ns d = g_t1 - g_t0 - ms(250);
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
int main()
{
{
m.lock();
g_mutex.lock();
boost::thread t(f1);
time_point t2 = Clock::now();
boost::this_thread::sleep_for(ms(250));
time_point t3 = Clock::now();
m.unlock();
g_mutex.unlock();
t.join();
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
BOOST_THREAD_TEST_IT(d_ns, ns(max_diff));
}
{
m.lock();
g_mutex.lock();
boost::thread t(f2);
boost::this_thread::sleep_for(ms(750));
m.unlock();
g_mutex.unlock();
t.join();
}
@@ -19,7 +19,7 @@
//#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
boost::mutex m;
boost::mutex g_mutex;
#if defined BOOST_THREAD_USES_CHRONO
@@ -28,8 +28,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -38,7 +38,7 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
auto
@@ -46,12 +46,12 @@ void f()
boost::unique_lock<boost::mutex>
#endif
//&&
_ = boost::make_unique_lock(m); (void)_;
t1 = Clock::now();
_ = boost::make_unique_lock(g_mutex); (void)_;
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
auto
@@ -59,17 +59,17 @@ void f()
boost::unique_lock<boost::mutex>
#endif
//&&
_ = boost::make_unique_lock(m); (void)_;
//t1 = Clock::now();
_ = boost::make_unique_lock(g_mutex); (void)_;
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -77,12 +77,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -17,7 +17,7 @@
#include <boost/core/lightweight_test.hpp>
#include "../../../../../timming.hpp"
boost::mutex m;
boost::mutex g_mutex;
#if defined BOOST_THREAD_USES_CHRONO
typedef boost::chrono::high_resolution_clock Clock;
@@ -25,8 +25,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -36,46 +36,46 @@ void f()
{
#if defined BOOST_THREAD_USES_CHRONO
{
t0 = Clock::now();
g_t0 = Clock::now();
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
auto
#else
boost::unique_lock<boost::mutex>
#endif
lk = boost::make_unique_lock(m, boost::try_to_lock);
lk = boost::make_unique_lock(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0;
g_t1 = Clock::now();
ns d = g_t1 - g_t0;
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
{
t0 = Clock::now();
g_t0 = Clock::now();
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
auto
#else
boost::unique_lock<boost::mutex>
#endif
lk = boost::make_unique_lock(m, boost::try_to_lock);
lk = boost::make_unique_lock(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0;
g_t1 = Clock::now();
ns d = g_t1 - g_t0;
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
{
t0 = Clock::now();
g_t0 = Clock::now();
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
auto
#else
boost::unique_lock<boost::mutex>
#endif
lk = boost::make_unique_lock(m, boost::try_to_lock);
lk = boost::make_unique_lock(g_mutex, boost::try_to_lock);
BOOST_TEST(lk.owns_lock() == false);
t1 = Clock::now();
ns d = t1 - t0;
g_t1 = Clock::now();
ns d = g_t1 - g_t0;
BOOST_THREAD_TEST_IT(d, ns(max_diff));
}
{
t0 = Clock::now();
g_t0 = Clock::now();
for (;;)
{
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
@@ -83,25 +83,25 @@ void f()
#else
boost::unique_lock<boost::mutex>
#endif
lk = boost::make_unique_lock(m, boost::try_to_lock);
lk = boost::make_unique_lock(g_mutex, boost::try_to_lock);
if (lk.owns_lock()) {
t1 = Clock::now();
g_t1 = Clock::now();
break;
}
}
}
#else
// time_point t0 = Clock::now();
// time_point g_t0 = Clock::now();
// {
// boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
// boost::unique_lock<boost::mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
// {
// boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
// boost::unique_lock<boost::mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
// {
// boost::unique_lock<boost::mutex> lk(m, boost::try_to_lock);
// boost::unique_lock<boost::mutex> lk(g_mutex, boost::try_to_lock);
// BOOST_TEST(lk.owns_lock() == false);
// }
for (;;)
@@ -111,18 +111,18 @@ void f()
#else
boost::unique_lock<boost::mutex>
#endif
lk = boost::make_unique_lock(m, boost::try_to_lock);
lk = boost::make_unique_lock(g_mutex, boost::try_to_lock);
if (lk.owns_lock()) break;
}
//time_point t1 = Clock::now();
//ns d = t1 - t0 - ms(250);
//time_point g_t1 = Clock::now();
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m.lock();
g_mutex.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -130,12 +130,12 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m.unlock();
g_mutex.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -18,9 +18,9 @@
#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
boost::mutex m1;
boost::mutex m2;
boost::mutex m3;
boost::mutex g_mutex1;
boost::mutex g_mutex2;
boost::mutex g_mutex3;
#if defined BOOST_THREAD_USES_CHRONO
@@ -30,8 +30,8 @@ typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef boost::chrono::milliseconds ms;
typedef boost::chrono::nanoseconds ns;
time_point t0;
time_point t1;
time_point g_t0;
time_point g_t1;
#else
#endif
@@ -40,28 +40,28 @@ const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
void f()
{
#if defined BOOST_THREAD_USES_CHRONO
t0 = Clock::now();
g_t0 = Clock::now();
{
auto&& _ = boost::make_unique_locks(m1,m2,m3); (void)_;
t1 = Clock::now();
auto&& _ = boost::make_unique_locks(g_mutex1,g_mutex2,g_mutex3); (void)_;
g_t1 = Clock::now();
}
#else
//time_point t0 = Clock::now();
//time_point t1;
//time_point g_t0 = Clock::now();
//time_point g_t1;
{
auto&& _ = boost::make_unique_locks(m1,m2,m3); (void)_;
//t1 = Clock::now();
auto&& _ = boost::make_unique_locks(g_mutex1,g_mutex2,g_mutex3); (void)_;
//g_t1 = Clock::now();
}
//ns d = t1 - t0 - ms(250);
//ns d = g_t1 - g_t0 - ms(250);
//BOOST_TEST(d < max_diff);
#endif
}
int main()
{
m1.lock();
m2.lock();
m3.lock();
g_mutex1.lock();
g_mutex2.lock();
g_mutex3.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
time_point t2 = Clock::now();
@@ -69,14 +69,14 @@ int main()
time_point t3 = Clock::now();
#else
#endif
m1.unlock();
m2.unlock();
m3.unlock();
g_mutex1.unlock();
g_mutex2.unlock();
g_mutex3.unlock();
t.join();
#if defined BOOST_THREAD_USES_CHRONO
ns sleep_time = t3 - t2;
ns d_ns = t1 - t0 - sleep_time;
ns d_ns = g_t1 - g_t0 - sleep_time;
ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
// BOOST_TEST_GE(d_ms.count(), 0);
BOOST_THREAD_TEST_IT(d_ms, max_diff);
@@ -23,30 +23,26 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m0;
boost::mutex m1;
boost::mutex g_mutex0;
boost::mutex g_mutex1;
int main()
{
{
boost::unique_lock<boost::mutex> lk0(m0);
boost::unique_lock<boost::mutex> lk1(m1);
boost::unique_lock<boost::mutex> lk0(g_mutex0);
boost::unique_lock<boost::mutex> lk1(g_mutex1);
lk1 = boost::move(lk0);
BOOST_TEST(lk1.mutex() == &m0);
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::unique_lock<boost::mutex> lk1;
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(m0));
BOOST_TEST(lk1.mutex() == &m0);
lk1 = BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(g_mutex0));
BOOST_TEST(lk1.mutex() == &g_mutex0);
BOOST_TEST(lk1.owns_lock() == true);
}
return boost::report_errors();
}
@@ -23,33 +23,33 @@
#include <boost/thread/mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::mutex m;
boost::mutex g_mutex;
int main()
{
{
boost::unique_lock<boost::mutex> lk0(m);
boost::unique_lock<boost::mutex> lk0(g_mutex);
boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::unique_lock<boost::mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(m))));
BOOST_TEST(lk.mutex() == &m);
boost::unique_lock<boost::mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(g_mutex))));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
}
{
boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
boost::unique_lock<boost::mutex> lk0(g_mutex, boost::defer_lock);
boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
boost::unique_lock<boost::mutex> lk0(g_mutex, boost::defer_lock);
lk0.release();
boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
BOOST_TEST(lk.mutex() == 0);
@@ -28,34 +28,34 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_mutex m;
boost::shared_mutex g_mutex;
int main()
{
{
boost::shared_lock<boost::shared_mutex> lk0(m);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex);
boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::unique_lock<boost::shared_mutex>
lk(boost::shared_lock<boost::shared_mutex>(m), boost::chrono::milliseconds(1));
BOOST_TEST(lk.mutex() == &m);
lk(boost::shared_lock<boost::shared_mutex>(g_mutex), boost::chrono::milliseconds(1));
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == true);
}
{
boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
BOOST_TEST(lk.mutex() == &m);
BOOST_TEST(lk.mutex() == &g_mutex);
BOOST_TEST(lk.owns_lock() == false);
BOOST_TEST(lk0.mutex() == 0);
BOOST_TEST(lk0.owns_lock() == false);
}
{
boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
boost::shared_lock<boost::shared_mutex> lk0(g_mutex, boost::defer_lock);
lk0.release();
boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::chrono::milliseconds(1));
BOOST_TEST(lk.mutex() == 0);

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