mirror of
https://github.com/boostorg/thread.git
synced 2026-02-04 09:52:14 +00:00
Compare commits
3 Commits
boost-1.60
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d04db8887 | ||
|
|
a636c8d605 | ||
|
|
55536c3e23 |
@@ -1432,6 +1432,10 @@ namespace boost
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
@@ -1444,6 +1448,11 @@ namespace boost
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_shared_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_shared_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
template<typename Ex, typename F, typename Rp, typename Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
@@ -1516,6 +1525,10 @@ namespace boost
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
@@ -1528,6 +1541,10 @@ namespace boost
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_shared_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_shared_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
template<typename Ex, typename F, typename Rp, typename Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
@@ -1772,6 +1789,10 @@ namespace boost
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
@@ -1784,6 +1805,10 @@ namespace boost
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_shared_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_shared_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, F f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
template<typename Ex, typename F, typename Rp, typename Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
@@ -2005,6 +2030,10 @@ namespace boost
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_sync_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
|
||||
template <class F, class Rp, class Fp>
|
||||
friend BOOST_THREAD_FUTURE<Rp>
|
||||
detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
|
||||
@@ -4210,12 +4239,6 @@ namespace detail {
|
||||
////////////////////////////////
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
|
||||
|
||||
#if defined BOOST_THREAD_CONTINUATION_SYNC
|
||||
#define continuation_shared_state_base shared_state
|
||||
#else
|
||||
#define continuation_shared_state_base future_async_shared_state_base
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
//////////////////////
|
||||
@@ -4345,26 +4368,43 @@ namespace detail
|
||||
/////////////////////////
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
struct future_async_continuation_shared_state: continuation_shared_state<F,Rp,Fp,continuation_shared_state_base<Rp> >
|
||||
struct future_async_continuation_shared_state: continuation_shared_state<F,Rp,Fp,future_async_shared_state_base<Rp> >
|
||||
{
|
||||
typedef continuation_shared_state<F,Rp,Fp,continuation_shared_state_base<Rp> > base_type;
|
||||
typedef continuation_shared_state<F,Rp,Fp,future_async_shared_state_base<Rp> > base_type;
|
||||
public:
|
||||
future_async_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
|
||||
: base_type(boost::move(f), boost::forward<Fp>(c))
|
||||
{ }
|
||||
|
||||
void launch_continuation() {
|
||||
#if defined BOOST_THREAD_CONTINUATION_SYNC
|
||||
this->call();
|
||||
#elif defined BOOST_THREAD_FUTURE_BLOCKING
|
||||
#if defined BOOST_THREAD_FUTURE_BLOCKING
|
||||
boost::lock_guard<boost::mutex> lk(this->mutex);
|
||||
this->thr_ = thread(&future_async_continuation_shared_state::run, static_shared_from_this(this));
|
||||
#else
|
||||
thread(&future_async_continuation_shared_state::run, static_shared_from_this(this)).detach();
|
||||
thread(&base_type::run, static_shared_from_this(this)).detach();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////
|
||||
/// future_sync_continuation_shared_state
|
||||
/////////////////////////
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
struct future_sync_continuation_shared_state: continuation_shared_state<F,Rp,Fp,shared_state<Rp> >
|
||||
{
|
||||
typedef continuation_shared_state<F,Rp,Fp,shared_state<Rp> > base_type;
|
||||
public:
|
||||
future_sync_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
|
||||
: base_type(boost::move(f), boost::forward<Fp>(c))
|
||||
{ }
|
||||
|
||||
void launch_continuation() {
|
||||
this->call();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////
|
||||
/// future_executor_continuation_shared_state
|
||||
/////////////////////////
|
||||
@@ -4445,9 +4485,9 @@ namespace detail {
|
||||
/////////////////////////
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
struct shared_future_async_continuation_shared_state: continuation_shared_state<F,Rp,Fp,continuation_shared_state_base<Rp> >
|
||||
struct shared_future_async_continuation_shared_state: continuation_shared_state<F,Rp,Fp,future_async_shared_state_base<Rp> >
|
||||
{
|
||||
typedef continuation_shared_state<F,Rp,Fp,continuation_shared_state_base<Rp> > base_type;
|
||||
typedef continuation_shared_state<F,Rp,Fp,future_async_shared_state_base<Rp> > base_type;
|
||||
|
||||
public:
|
||||
shared_future_async_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
|
||||
@@ -4456,19 +4496,36 @@ namespace detail {
|
||||
}
|
||||
|
||||
void launch_continuation() {
|
||||
#if defined BOOST_THREAD_CONTINUATION_SYNC
|
||||
this->call();
|
||||
#elif defined BOOST_THREAD_FUTURE_BLOCKING
|
||||
#if defined BOOST_THREAD_FUTURE_BLOCKING
|
||||
boost::lock_guard<boost::mutex> lk(this->mutex);
|
||||
this->thr_ = thread(&shared_future_async_continuation_shared_state::run, static_shared_from_this(this));
|
||||
this->thr_ = thread(&base_type::run, static_shared_from_this(this));
|
||||
#else
|
||||
thread(&shared_future_async_continuation_shared_state::run, static_shared_from_this(this)).detach();
|
||||
thread(&base_type::run, static_shared_from_this(this)).detach();
|
||||
#endif
|
||||
}
|
||||
|
||||
~shared_future_async_continuation_shared_state() {}
|
||||
};
|
||||
|
||||
/////////////////////////
|
||||
/// shared_future_async_continuation_shared_state
|
||||
/////////////////////////
|
||||
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
struct shared_future_sync_continuation_shared_state: continuation_shared_state<F,Rp,Fp,shared_state<Rp> >
|
||||
{
|
||||
typedef continuation_shared_state<F,Rp,Fp,shared_state<Rp> > base_type;
|
||||
|
||||
public:
|
||||
shared_future_sync_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
|
||||
: base_type(boost::move(f), boost::forward<Fp>(c))
|
||||
{
|
||||
}
|
||||
|
||||
void launch_continuation() {
|
||||
this->call();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////
|
||||
/// shared_future_executor_continuation_shared_state
|
||||
/////////////////////////
|
||||
@@ -4577,6 +4634,21 @@ namespace detail {
|
||||
|
||||
return BOOST_THREAD_FUTURE<Rp>(h);
|
||||
}
|
||||
////////////////////////////////
|
||||
// make_future_sync_continuation_shared_state
|
||||
////////////////////////////////
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_future_sync_continuation_shared_state(
|
||||
boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f,
|
||||
BOOST_THREAD_FWD_REF(Fp) c) {
|
||||
typedef typename decay<Fp>::type Cont;
|
||||
shared_ptr<future_sync_continuation_shared_state<F,Rp, Cont> >
|
||||
h(new future_sync_continuation_shared_state<F,Rp, Cont>(boost::move(f), boost::forward<Fp>(c)));
|
||||
h->init(lock);
|
||||
|
||||
return BOOST_THREAD_FUTURE<Rp>(h);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// make_future_executor_continuation_shared_state
|
||||
@@ -4628,6 +4700,21 @@ namespace detail {
|
||||
return BOOST_THREAD_FUTURE<Rp>(h);
|
||||
}
|
||||
////////////////////////////////
|
||||
// make_shared_future_sync_continuation_shared_state
|
||||
////////////////////////////////
|
||||
template<typename F, typename Rp, typename Fp>
|
||||
BOOST_THREAD_FUTURE<Rp>
|
||||
make_shared_future_sync_continuation_shared_state(
|
||||
boost::unique_lock<boost::mutex> &lock, F f,
|
||||
BOOST_THREAD_FWD_REF(Fp) c) {
|
||||
typedef typename decay<Fp>::type Cont;
|
||||
shared_ptr<shared_future_sync_continuation_shared_state<F,Rp, Cont> >
|
||||
h(new shared_future_sync_continuation_shared_state<F,Rp, Cont>(f, boost::forward<Fp>(c)));
|
||||
h->init(lock);
|
||||
|
||||
return BOOST_THREAD_FUTURE<Rp>(h);
|
||||
}
|
||||
////////////////////////////////
|
||||
// make_shared_future_executor_continuation_shared_state
|
||||
////////////////////////////////
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
@@ -4787,6 +4874,10 @@ namespace detail {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
|
||||
assert(this->future_->get_executor());
|
||||
@@ -4807,6 +4898,10 @@ namespace detail {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
|
||||
assert(this->future_->get_executor());
|
||||
@@ -4878,7 +4973,7 @@ namespace detail {
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
} else {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>(
|
||||
lock, boost::move(*this), boost::forward<F>(func)
|
||||
)));
|
||||
}
|
||||
@@ -4906,6 +5001,10 @@ namespace detail {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state<shared_future<R>, future_type>(
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state<shared_future<R>, future_type>(
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
|
||||
typedef executor Ex;
|
||||
@@ -4925,6 +5024,10 @@ namespace detail {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state<shared_future<R>, future_type>(
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
} else if (underlying_cast<int>(policy) & int(launch::sync)) {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state<shared_future<R>, future_type>(
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
|
||||
} else if (underlying_cast<int>(policy) & int(launch::executor)) {
|
||||
typedef executor Ex;
|
||||
@@ -4986,7 +5089,7 @@ namespace detail {
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
} else {
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state<shared_future<R>, future_type>(
|
||||
return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state<shared_future<R>, future_type>(
|
||||
lock, *this, boost::forward<F>(func)
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace boost
|
||||
executor = 4,
|
||||
#endif
|
||||
inherit = 8,
|
||||
sync = 16,
|
||||
any = async | deferred
|
||||
}
|
||||
BOOST_SCOPED_ENUM_DECLARE_END(launch)
|
||||
|
||||
Reference in New Issue
Block a user