mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::ctx: Resolve proper future::state() in when() templates.
This commit is contained in:
parent
386901f4c2
commit
4cd0570d56
2 changed files with 24 additions and 7 deletions
|
@ -90,6 +90,9 @@ struct ircd::ctx::future<void>
|
|||
|
||||
namespace ircd::ctx
|
||||
{
|
||||
template<class T> const shared_state<T> &state(const future<T> &);
|
||||
template<class T> shared_state<T> &state(future<T> &);
|
||||
|
||||
template<class T,
|
||||
class time_point>
|
||||
bool wait_until(const future<T> &, const time_point &, std::nothrow_t);
|
||||
|
@ -351,3 +354,17 @@ ircd::ctx::wait_until(const future<T> &f,
|
|||
|
||||
return wfun();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ircd::ctx::shared_state<T> &
|
||||
ircd::ctx::state(future<T> &future)
|
||||
{
|
||||
return future.state();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const ircd::ctx::shared_state<T> &
|
||||
ircd::ctx::state(const future<T> &future)
|
||||
{
|
||||
return future.state();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ ircd::ctx::when_all(it first,
|
|||
{
|
||||
[&p](it &f)
|
||||
{
|
||||
f->state().then = [p]
|
||||
state(*f).then = [p]
|
||||
(shared_state_base &) mutable
|
||||
{
|
||||
then(p);
|
||||
|
@ -54,7 +54,7 @@ ircd::ctx::when_all(it first,
|
|||
|
||||
future<void> ret(p);
|
||||
for(; first != last; ++first)
|
||||
if(is(first->state(), future_state::PENDING))
|
||||
if(is(state(*first), future_state::PENDING))
|
||||
set_then(first);
|
||||
|
||||
if(refcount(p.state()) <= 1)
|
||||
|
@ -85,7 +85,7 @@ ircd::ctx::when_any(it first,
|
|||
if(!p.valid())
|
||||
return;
|
||||
|
||||
set(f->state(), future_state::OBSERVED);
|
||||
set(state(*f), future_state::OBSERVED);
|
||||
p.set_value(f);
|
||||
}
|
||||
};
|
||||
|
@ -95,7 +95,7 @@ ircd::ctx::when_any(it first,
|
|||
{
|
||||
[&p](it &f)
|
||||
{
|
||||
f->state().then = [p, f] // alloc
|
||||
state(*f).then = [p, f] // alloc
|
||||
(shared_state_base &) mutable
|
||||
{
|
||||
then(p, f);
|
||||
|
@ -105,15 +105,15 @@ ircd::ctx::when_any(it first,
|
|||
|
||||
future<it> ret(p);
|
||||
for(auto f(first); f != last; ++f)
|
||||
if(is(f->state(), future_state::READY))
|
||||
if(is(state(*f), future_state::READY))
|
||||
{
|
||||
set(f->state(), future_state::OBSERVED);
|
||||
set(state(*f), future_state::OBSERVED);
|
||||
p.set_value(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for(; first != last; ++first)
|
||||
if(is(first->state(), future_state::PENDING))
|
||||
if(is(state(*first), future_state::PENDING))
|
||||
set_then(first);
|
||||
|
||||
if(refcount(p.state()) <= 1)
|
||||
|
|
Loading…
Reference in a new issue