mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 16:46:50 +01:00
ircd::ctx::future: Add non-std get() w/ durations to avoid separate wait().
This commit is contained in:
parent
b4842da414
commit
0efc56c9c7
1 changed files with 20 additions and 0 deletions
|
@ -57,6 +57,8 @@ struct ircd::ctx::future
|
|||
void wait() const;
|
||||
|
||||
T get();
|
||||
template<class duration> T get(const duration &d);
|
||||
template<class time_point> T get_until(const time_point &);
|
||||
|
||||
future() = default;
|
||||
future(promise<T> &promise);
|
||||
|
@ -209,6 +211,24 @@ noexcept
|
|||
invalidate(state());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class time_point>
|
||||
T
|
||||
ircd::ctx::future<T>::get_until(const time_point &tp)
|
||||
{
|
||||
this->wait_until(tp);
|
||||
return this->get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class duration>
|
||||
T
|
||||
ircd::ctx::future<T>::get(const duration &d)
|
||||
{
|
||||
this->wait(d);
|
||||
return this->get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T
|
||||
ircd::ctx::future<T>::get()
|
||||
|
|
Loading…
Reference in a new issue