mirror of
https://github.com/boostorg/thread.git
synced 2026-02-03 21:52:07 +00:00
Compare commits
12 Commits
boost-1.59
...
fix/basic_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba2988a8f7 | ||
|
|
e598796eaf | ||
|
|
bce7eabba2 | ||
|
|
0218136ed7 | ||
|
|
461bf803fc | ||
|
|
1bd78bbeea | ||
|
|
348da6b7e4 | ||
|
|
e850218c49 | ||
|
|
385eefd3b3 | ||
|
|
c9433c2a5b | ||
|
|
8853a4cbdf | ||
|
|
6f53279b50 |
@@ -27,8 +27,10 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
boost::future<void> p(boost::future<void>) {
|
||||
boost::future<void> p(boost::future<void> f) {
|
||||
assert(f.is_ready());
|
||||
return boost::make_ready_future();
|
||||
}
|
||||
|
||||
@@ -156,10 +158,13 @@ int main()
|
||||
&& defined BOOST_THREAD_PROVIDES_EXECUTORS \
|
||||
&& ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
boost::basic_thread_pool executor;
|
||||
// compiles
|
||||
boost::make_ready_future().then(&p);
|
||||
|
||||
boost::basic_thread_pool executor;
|
||||
// ??
|
||||
boost::make_ready_future().then(executor, &p);
|
||||
|
||||
// doesn't compile
|
||||
boost::make_ready_future().then(executor, &p);
|
||||
#endif
|
||||
|
||||
@@ -94,6 +94,11 @@ int main()
|
||||
f.get();
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
|
||||
boost::future<int> f = compute(-1);
|
||||
f.wait();
|
||||
}
|
||||
{
|
||||
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
|
||||
boost::future<int> f = compute(0);
|
||||
@@ -124,11 +129,11 @@ int main()
|
||||
boost::future<int const&> f = boost::make_ready_future(boost::cref(i));
|
||||
std::cout << f.get() << std::endl;
|
||||
}
|
||||
// {
|
||||
// std::cout << __FILE__ << " "<< __LINE__ << std::endl;
|
||||
// boost::future<int> f = compute(2);
|
||||
// std::cout << f.get() << std::endl;
|
||||
// }
|
||||
{
|
||||
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
|
||||
boost::future<int> f = compute(2);
|
||||
std::cout << f.get() << std::endl;
|
||||
}
|
||||
{
|
||||
std::cout << __FILE__ << " "<< __LINE__ << std::endl;
|
||||
boost::shared_future<int> f = shared_compute(0);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#endif
|
||||
#include <boost/thread/concurrent_queues/sync_queue.hpp>
|
||||
|
||||
void producer(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
void producer(the_ostream & /*mos*/, boost::sync_queue<int> & sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -32,22 +32,22 @@ void producer(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
{
|
||||
sbq.push(i);
|
||||
//sbq << i;
|
||||
mos << "push(" << i << ") "<< sbq.size()<<"\n";
|
||||
//mos << "push(" << i << ") "<< sbq.size()<<"\n";
|
||||
this_thread::sleep_for(chrono::milliseconds(200));
|
||||
}
|
||||
}
|
||||
catch(sync_queue_is_closed&)
|
||||
{
|
||||
mos << "closed !!!\n";
|
||||
//mos << "closed !!!\n";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
|
||||
void consumer(
|
||||
the_ostream &mos,
|
||||
the_ostream & /*mos*/,
|
||||
boost::sync_queue<int> & sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
@@ -57,21 +57,21 @@ void consumer(
|
||||
int r;
|
||||
sbq.pull(r);
|
||||
//sbq >> r;
|
||||
mos << i << " pull(" << r << ") "<< sbq.size()<<"\n";
|
||||
//mos << i << " pull(" << r << ") "<< sbq.size()<<"\n";
|
||||
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(sync_queue_is_closed&)
|
||||
{
|
||||
mos << "closed !!!\n";
|
||||
//mos << "closed !!!\n";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
void consumer2(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
void consumer2(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -81,17 +81,17 @@ void consumer2(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
queue_op_status st = sbq.try_pull(r);
|
||||
if (queue_op_status::closed == st) break;
|
||||
if (queue_op_status::success == st) {
|
||||
mos << i << " pull(" << r << ")\n";
|
||||
//mos << i << " pull(" << r << ")\n";
|
||||
}
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
void consumer3(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
void consumer3(the_ostream &/*mos*/, boost::sync_queue<int> & sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -100,13 +100,13 @@ void consumer3(the_ostream &mos, boost::sync_queue<int> & sbq)
|
||||
int r;
|
||||
queue_op_status res = sbq.wait_pull(r);
|
||||
if (res==queue_op_status::closed) break;
|
||||
mos << i << " wait_pull(" << r << ")\n";
|
||||
//mos << i << " wait_pull(" << r << ")\n";
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
void producer(the_ostream &mos, boost::queue_back<int> sbq)
|
||||
void producer(the_ostream &/*mos*/, boost::queue_back<int> sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -35,22 +35,22 @@ void producer(the_ostream &mos, boost::queue_back<int> sbq)
|
||||
{
|
||||
sbq.push(i);
|
||||
//sbq << i;
|
||||
mos << "push(" << i << ") " << sbq.size() <<"\n";
|
||||
//mos << "push(" << i << ") " << sbq.size() <<"\n";
|
||||
this_thread::sleep_for(chrono::milliseconds(200));
|
||||
}
|
||||
}
|
||||
catch(sync_queue_is_closed&)
|
||||
{
|
||||
mos << "closed !!!\n";
|
||||
//mos << "closed !!!\n";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
|
||||
void consumer(
|
||||
the_ostream &mos,
|
||||
the_ostream &/*mos*/,
|
||||
boost::queue_front<int> sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
@@ -60,21 +60,21 @@ void consumer(
|
||||
int r;
|
||||
sbq.pull(r);
|
||||
//sbq >> r;
|
||||
mos << i << " pull(" << r << ") " << sbq.size() <<"\n";
|
||||
//mos << i << " pull(" << r << ") " << sbq.size() <<"\n";
|
||||
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(sync_queue_is_closed&)
|
||||
{
|
||||
mos << "closed !!!\n";
|
||||
//mos << "closed !!!\n";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
void consumer2(the_ostream &mos, boost::queue_front<int> sbq)
|
||||
void consumer2(the_ostream &/*mos*/, boost::queue_front<int> sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -84,17 +84,17 @@ void consumer2(the_ostream &mos, boost::queue_front<int> sbq)
|
||||
queue_op_status st = sbq.try_pull(r);
|
||||
if (queue_op_status::closed == st) break;
|
||||
if (queue_op_status::success == st) {
|
||||
mos << i << " try_pull(" << r << ")\n";
|
||||
//mos << i << " try_pull(" << r << ")\n";
|
||||
}
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
void consumer3(the_ostream &mos, boost::queue_front<int> sbq)
|
||||
void consumer3(the_ostream &/*mos*/, boost::queue_front<int> sbq)
|
||||
{
|
||||
using namespace boost;
|
||||
try {
|
||||
@@ -103,13 +103,13 @@ void consumer3(the_ostream &mos, boost::queue_front<int> sbq)
|
||||
int r;
|
||||
queue_op_status res = sbq.wait_pull(r);
|
||||
if (res==queue_op_status::closed) break;
|
||||
mos << i << " wait_pull(" << r << ")\n";
|
||||
//mos << i << " wait_pull(" << r << ")\n";
|
||||
this_thread::sleep_for(chrono::milliseconds(250));
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
mos << "exception !!!\n";
|
||||
//mos << "exception !!!\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ counter c;
|
||||
|
||||
void change_count()
|
||||
{
|
||||
std::cout << "count == " << c.increment() << std::endl;
|
||||
//std::cout << "count == " << c.increment() << std::endl;
|
||||
}
|
||||
|
||||
int main(int, char*[])
|
||||
|
||||
@@ -27,16 +27,16 @@
|
||||
|
||||
void p1()
|
||||
{
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
//std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(30));
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
//std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
}
|
||||
|
||||
void p2()
|
||||
{
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
//std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
//std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
}
|
||||
|
||||
int f1()
|
||||
@@ -54,7 +54,6 @@ int f2(int i)
|
||||
|
||||
void submit_some(boost::serial_executor& tp)
|
||||
{
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
tp.submit(&p2);
|
||||
@@ -63,7 +62,6 @@ void submit_some(boost::serial_executor& tp)
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
tp.submit(&p1);
|
||||
}
|
||||
std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -75,13 +73,11 @@ void at_th_entry(boost::basic_thread_pool& )
|
||||
|
||||
int test_executor_adaptor()
|
||||
{
|
||||
// std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
// std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
{
|
||||
boost::basic_thread_pool ea1(4);
|
||||
boost::serial_executor ea2(ea1);
|
||||
@@ -89,7 +85,6 @@ int test_executor_adaptor()
|
||||
boost::this_thread::sleep_for(boost::chrono::seconds(10));
|
||||
}
|
||||
#endif
|
||||
// std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
@@ -102,7 +97,6 @@ int test_executor_adaptor()
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
// std::cout << BOOST_CONTEXTOF << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ int main()
|
||||
threads.remove_thread(th);
|
||||
BOOST_TEST(! threads.is_thread_in(th));
|
||||
th->join();
|
||||
delete th;
|
||||
}
|
||||
{
|
||||
{
|
||||
|
||||
@@ -173,7 +173,6 @@ namespace boost
|
||||
private:
|
||||
bool start_thread_noexcept();
|
||||
bool start_thread_noexcept(const attributes& attr);
|
||||
//public:
|
||||
void start_thread()
|
||||
{
|
||||
if (!start_thread_noexcept())
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
#include <boost/thread/detail/delete.hpp>
|
||||
#include <boost/thread/detail/move.hpp>
|
||||
#include <boost/thread/scoped_thread.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/concurrent_queues/sync_queue.hpp>
|
||||
#include <boost/thread/executors/work.hpp>
|
||||
#include <boost/thread/csbl/vector.hpp>
|
||||
@@ -30,15 +30,14 @@ namespace executors
|
||||
/// type-erasure to store the works to do
|
||||
typedef executors::work work;
|
||||
private:
|
||||
/// the kind of stored threads are scoped threads to ensure that the threads are joined.
|
||||
typedef thread thread_t;
|
||||
/// A move aware vector type
|
||||
typedef scoped_thread<> thread_t;
|
||||
typedef csbl::vector<thread_t> thread_vector;
|
||||
|
||||
/// the thread safe work queue
|
||||
concurrent::sync_queue<work > work_queue;
|
||||
/// A move aware vector
|
||||
thread_vector threads;
|
||||
/// the thread safe work queue
|
||||
concurrent::sync_queue<work > work_queue;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -222,7 +221,8 @@ namespace executors
|
||||
{
|
||||
// signal to all the worker threads that there will be no more submissions.
|
||||
close();
|
||||
// joins all the threads as the threads were scoped_threads
|
||||
// joins all the threads before destroying the thread pool resources (e.g. the queue).
|
||||
join();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,6 +150,19 @@ namespace boost
|
||||
policy_(launch::none),
|
||||
continuations()
|
||||
{}
|
||||
|
||||
shared_state_base(exceptional_ptr const& ex):
|
||||
exception(ex.ptr_),
|
||||
done(true),
|
||||
is_valid_(true),
|
||||
is_deferred_(false),
|
||||
is_constructed(false),
|
||||
cnt_(0),
|
||||
policy_(launch::none),
|
||||
continuations()
|
||||
{}
|
||||
|
||||
|
||||
virtual ~shared_state_base()
|
||||
{
|
||||
BOOST_ASSERT(cnt_==0);
|
||||
@@ -483,6 +496,10 @@ namespace boost
|
||||
shared_state():
|
||||
result()
|
||||
{}
|
||||
shared_state(exceptional_ptr const& ex):
|
||||
detail::shared_state_base(ex), result()
|
||||
{}
|
||||
|
||||
|
||||
~shared_state()
|
||||
{}
|
||||
@@ -624,6 +641,10 @@ namespace boost
|
||||
result(0)
|
||||
{}
|
||||
|
||||
shared_state(exceptional_ptr const& ex):
|
||||
detail::shared_state_base(ex), result(0)
|
||||
{}
|
||||
|
||||
~shared_state()
|
||||
{
|
||||
}
|
||||
@@ -687,6 +708,10 @@ namespace boost
|
||||
shared_state()
|
||||
{}
|
||||
|
||||
shared_state(exceptional_ptr const& ex):
|
||||
detail::shared_state_base(ex)
|
||||
{}
|
||||
|
||||
void mark_finished_with_result_internal(boost::unique_lock<boost::mutex>& lock)
|
||||
{
|
||||
mark_finished_internal(lock);
|
||||
@@ -1150,16 +1175,15 @@ namespace boost
|
||||
|
||||
static //BOOST_CONSTEXPR
|
||||
future_ptr make_exceptional_future_ptr(exceptional_ptr const& ex) {
|
||||
promise<R> p;
|
||||
p.set_exception(ex.ptr_);
|
||||
return p.get_future().future_;
|
||||
return future_ptr(new detail::shared_state<R>(ex));
|
||||
}
|
||||
|
||||
void set_exceptional_if_invalid() {
|
||||
if (valid()) return;
|
||||
promise<R> p;
|
||||
p.set_exception(future_uninitialized());
|
||||
future_ = p.get_future().future_;
|
||||
// promise<R> p;
|
||||
// p.set_exception(future_uninitialized());
|
||||
// future_ = p.get_future().future_;
|
||||
future_ = make_exceptional_future_ptr(exceptional_ptr(future_uninitialized()));
|
||||
}
|
||||
|
||||
future_ptr future_;
|
||||
@@ -4092,12 +4116,6 @@ namespace detail {
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
BOOST_THREAD_FUTURE<T> make_ready_future(exception_ptr ex) {
|
||||
promise<T> p;
|
||||
p.set_exception(ex);
|
||||
return BOOST_THREAD_MAKE_RV_REF(p.get_future());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_THREAD_FUTURE<T> make_exceptional_future(exception_ptr ex) {
|
||||
@@ -4119,6 +4137,10 @@ namespace detail {
|
||||
p.set_exception(boost::current_exception());
|
||||
return BOOST_THREAD_MAKE_RV_REF(p.get_future());
|
||||
}
|
||||
template <typename T>
|
||||
BOOST_THREAD_FUTURE<T> make_ready_future(exception_ptr ex) {
|
||||
return make_exceptional_future<T>(ex);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_THREAD_FUTURE<T> make_exceptional_future_if_invalid(BOOST_THREAD_FWD_REF(BOOST_THREAD_FUTURE<T>) fut) {
|
||||
|
||||
@@ -120,6 +120,15 @@ namespace boost
|
||||
unique_lock<mutex>& m,
|
||||
duration_type const& wait_duration)
|
||||
{
|
||||
if (wait_duration.is_pos_infinity())
|
||||
{
|
||||
wait(m); // or do_wait(m,detail::timeout::sentinel());
|
||||
return true;
|
||||
}
|
||||
if (wait_duration.is_special())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return timed_wait(m,get_system_time()+wait_duration);
|
||||
}
|
||||
|
||||
@@ -149,6 +158,18 @@ namespace boost
|
||||
unique_lock<mutex>& m,
|
||||
duration_type const& wait_duration,predicate_type pred)
|
||||
{
|
||||
if (wait_duration.is_pos_infinity())
|
||||
{
|
||||
while (!pred())
|
||||
{
|
||||
wait(m); // or do_wait(m,detail::timeout::sentinel());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (wait_duration.is_special())
|
||||
{
|
||||
return pred();
|
||||
}
|
||||
return timed_wait(m,get_system_time()+wait_duration,pred);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -339,8 +339,8 @@ namespace boost
|
||||
{
|
||||
if (wait_duration.is_pos_infinity())
|
||||
{
|
||||
wait(m); // or do_wait(m,detail::timeout::sentinel());
|
||||
return true;
|
||||
wait(m); // or do_wait(m,detail::timeout::sentinel());
|
||||
return true;
|
||||
}
|
||||
if (wait_duration.is_special())
|
||||
{
|
||||
@@ -362,6 +362,18 @@ namespace boost
|
||||
template<typename duration_type,typename predicate_type>
|
||||
bool timed_wait(unique_lock<mutex>& m,duration_type const& wait_duration,predicate_type pred)
|
||||
{
|
||||
if (wait_duration.is_pos_infinity())
|
||||
{
|
||||
while (!pred())
|
||||
{
|
||||
wait(m); // or do_wait(m,detail::timeout::sentinel());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (wait_duration.is_special())
|
||||
{
|
||||
return pred();
|
||||
}
|
||||
return do_wait(m,wait_duration.total_milliseconds(),pred);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace boost
|
||||
static void tls_destructor(void* data)
|
||||
{
|
||||
boost::detail::thread_data_base* thread_info=static_cast<boost::detail::thread_data_base*>(data);
|
||||
//boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(data)->shared_from_this();
|
||||
|
||||
if(thread_info)
|
||||
{
|
||||
while(!thread_info->tss_data.empty() || thread_info->thread_exit_callbacks)
|
||||
@@ -158,8 +160,9 @@ namespace boost
|
||||
{
|
||||
static void* thread_proxy(void* param)
|
||||
{
|
||||
boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
|
||||
//thread_info->self.reset();
|
||||
//boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
|
||||
boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->shared_from_this();
|
||||
thread_info->self.reset();
|
||||
detail::set_current_thread_data(thread_info.get());
|
||||
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
|
||||
BOOST_TRY
|
||||
@@ -252,7 +255,6 @@ namespace boost
|
||||
{
|
||||
thread_info->self.reset();
|
||||
return false;
|
||||
// boost::throw_exception(thread_resource_error(res, "boost thread: failed in pthread_create"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -266,7 +268,6 @@ namespace boost
|
||||
{
|
||||
thread_info->self.reset();
|
||||
return false;
|
||||
// boost::throw_exception(thread_resource_error(res, "boost thread: failed in pthread_create"));
|
||||
}
|
||||
int detached_state;
|
||||
res = pthread_attr_getdetachstate(h, &detached_state);
|
||||
@@ -274,7 +275,6 @@ namespace boost
|
||||
{
|
||||
thread_info->self.reset();
|
||||
return false;
|
||||
// boost::throw_exception(thread_resource_error(res, "boost thread: failed in pthread_attr_getdetachstate"));
|
||||
}
|
||||
if (PTHREAD_CREATE_DETACHED==detached_state)
|
||||
{
|
||||
|
||||
@@ -947,11 +947,19 @@ rule thread-compile ( sources : reqs * : name )
|
||||
[ thread-run2-noit ./experimental/parallel/v2/task_region_pass.cpp : task_region_p ]
|
||||
;
|
||||
|
||||
explicit ts_ ;
|
||||
test-suite ts_
|
||||
explicit ts_other ;
|
||||
test-suite ts_other
|
||||
:
|
||||
[ thread-run2 ../example/this_executor.cpp : ex_this_executor ]
|
||||
[ thread-run2 ../example/default_executor.cpp : ex_default_executor ]
|
||||
;
|
||||
|
||||
explicit ts_ ;
|
||||
test-suite ts_
|
||||
:
|
||||
#[ thread-compile test_10963.cpp : : test_10963_c ]
|
||||
#[ thread-run test_10964.cpp ]
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
|
||||
|
||||
@@ -31,6 +32,8 @@ int p1()
|
||||
|
||||
int p2(boost::future<int> f)
|
||||
{
|
||||
assert(f.is_ready());
|
||||
|
||||
BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
|
||||
BOOST_TEST(f.valid());
|
||||
int i = f.get();
|
||||
@@ -41,6 +44,7 @@ int p2(boost::future<int> f)
|
||||
|
||||
void p3(boost::future<int> f)
|
||||
{
|
||||
assert(f.is_ready());
|
||||
BOOST_THREAD_LOG << "p3 <" << &f << BOOST_THREAD_END_LOG;
|
||||
BOOST_TEST(f.valid());
|
||||
int i = f.get();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/thread/executors/basic_thread_pool.hpp>
|
||||
#include <boost/thread/executor.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
|
||||
|
||||
@@ -34,6 +35,7 @@ int p1()
|
||||
|
||||
int p2(boost::future<int> f)
|
||||
{
|
||||
assert(f.is_ready());
|
||||
BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
|
||||
BOOST_TEST(f.valid());
|
||||
int i = f.get();
|
||||
@@ -44,6 +46,7 @@ int p2(boost::future<int> f)
|
||||
|
||||
void p3(boost::future<int> f)
|
||||
{
|
||||
assert(f.is_ready());
|
||||
BOOST_THREAD_LOG << "p3 <" << &f << BOOST_THREAD_END_LOG;
|
||||
BOOST_TEST(f.valid());
|
||||
int i = f.get();
|
||||
|
||||
@@ -8,9 +8,12 @@
|
||||
#if ! defined BOOST_NO_CXX11_DECLTYPE
|
||||
#define BOOST_RESULT_OF_USE_DECLTYPE
|
||||
#endif
|
||||
#define BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/thread/executors/basic_thread_pool.hpp>
|
||||
|
||||
|
||||
struct TestCallback
|
||||
@@ -19,12 +22,14 @@ struct TestCallback
|
||||
|
||||
result_type operator()(boost::future<void> future) const
|
||||
{
|
||||
assert(future.is_ready());
|
||||
future.get();
|
||||
return boost::make_ready_future();
|
||||
}
|
||||
|
||||
result_type operator()(boost::future<boost::future<void> > future) const
|
||||
{
|
||||
assert(future.is_ready());
|
||||
future.get();
|
||||
return boost::make_ready_future();
|
||||
}
|
||||
@@ -33,12 +38,24 @@ struct TestCallback
|
||||
int main()
|
||||
{
|
||||
#if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
|
||||
{
|
||||
boost::promise<void> test_promise;
|
||||
boost::future<void> test_future(test_promise.get_future());
|
||||
auto f1 = test_future.then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
auto f2 = f1.then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<boost::future<void> > >::value);
|
||||
}
|
||||
{
|
||||
boost::basic_thread_pool executor;
|
||||
boost::promise<void> test_promise;
|
||||
boost::future<void> test_future(test_promise.get_future());
|
||||
auto f1 = test_future.then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
auto f2 = f1.then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<boost::future<void> > >::value);
|
||||
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,12 @@
|
||||
#if ! defined BOOST_NO_CXX11_DECLTYPE
|
||||
#define BOOST_RESULT_OF_USE_DECLTYPE
|
||||
#endif
|
||||
#define BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/thread/executors/basic_thread_pool.hpp>
|
||||
|
||||
struct TestCallback
|
||||
{
|
||||
@@ -18,13 +21,23 @@ struct TestCallback
|
||||
|
||||
result_type operator()(boost::future<void> future) const
|
||||
{
|
||||
future.get();
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
assert(future.is_ready());
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
future.wait();
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
return boost::make_ready_future();
|
||||
}
|
||||
|
||||
result_type operator()(boost::future<boost::future<void> > future) const
|
||||
{
|
||||
future.get();
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
assert(future.is_ready());
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
assert(future.get().is_ready());
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
//boost::future<void> ff = future.get();
|
||||
|
||||
return boost::make_ready_future();
|
||||
}
|
||||
};
|
||||
@@ -51,13 +64,23 @@ int main()
|
||||
f2.wait();
|
||||
}
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
auto f1 = boost::make_ready_future().then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
boost::future<void> f2 = f1.get();
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
}
|
||||
#if 0
|
||||
// @fixme this doesn't works.
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
auto f1 = boost::make_ready_future().then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
auto f2 = f1.unwrap();
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<void> >::value);
|
||||
auto f3 = f2.then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f3), boost::future<boost::future<void> > >::value);
|
||||
f3.wait();
|
||||
}
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
@@ -71,6 +94,62 @@ int main()
|
||||
f.then(
|
||||
TestCallback()).unwrap().then(TestCallback()).get();
|
||||
}
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
auto f1 = boost::make_ready_future().then(TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
auto f3 = f1.then(TestCallback());
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f3), boost::future<boost::future<void> > >::value);
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
f3.wait();
|
||||
}
|
||||
|
||||
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
boost::basic_thread_pool executor;
|
||||
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
auto f1 = boost::make_ready_future().then(executor, TestCallback());
|
||||
//BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
auto f3 = f1.then(executor, TestCallback());
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f3), boost::future<boost::future<void> > >::value);
|
||||
f3.wait();
|
||||
}
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
boost::basic_thread_pool executor;
|
||||
|
||||
auto f1 = boost::make_ready_future().then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
auto f2 = f1.unwrap();
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<void> >::value);
|
||||
auto f3 = f2.then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f3), boost::future<boost::future<void> > >::value);
|
||||
f3.wait();
|
||||
}
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
{
|
||||
boost::basic_thread_pool executor;
|
||||
|
||||
auto f1 = boost::make_ready_future().then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
|
||||
auto f2 = f1.unwrap();
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<void> >::value);
|
||||
auto f3 = f2.then(executor, TestCallback());
|
||||
BOOST_STATIC_ASSERT(std::is_same<decltype(f3), boost::future<boost::future<void> > >::value);
|
||||
f3.wait();
|
||||
}
|
||||
#endif
|
||||
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user