mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 15:30:52 +01:00
Revert "ircd::ctx: Add nodejs-style future::then() rather than libstd experimental TS."
This reverts commit 37569559cf
.
This commit is contained in:
parent
28c7826032
commit
4fa33bdc60
3 changed files with 0 additions and 42 deletions
|
@ -58,8 +58,6 @@ class ircd::ctx::future
|
||||||
T get();
|
T get();
|
||||||
operator T() { return get(); }
|
operator T() { return get(); }
|
||||||
|
|
||||||
void then(decltype(shared_state<T>::callback));
|
|
||||||
|
|
||||||
future();
|
future();
|
||||||
future(promise<T> &promise);
|
future(promise<T> &promise);
|
||||||
};
|
};
|
||||||
|
@ -84,8 +82,6 @@ class ircd::ctx::future<void>
|
||||||
template<class duration> future_status wait(const duration &d) const;
|
template<class duration> future_status wait(const duration &d) const;
|
||||||
void wait() const;
|
void wait() const;
|
||||||
|
|
||||||
void then(decltype(shared_state<void>::callback));
|
|
||||||
|
|
||||||
future();
|
future();
|
||||||
future(promise<void> &promise);
|
future(promise<void> &promise);
|
||||||
};
|
};
|
||||||
|
@ -140,21 +136,6 @@ ircd::ctx::future<T>::future(promise<T> &promise)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void
|
|
||||||
ircd::ctx::future<T>::then(decltype(shared_state<T>::callback) cb)
|
|
||||||
{
|
|
||||||
assert(valid());
|
|
||||||
st->callback = std::move(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
ircd::ctx::future<void>::then(decltype(shared_state<void>::callback) cb)
|
|
||||||
{
|
|
||||||
assert(valid());
|
|
||||||
st->callback = std::move(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T
|
T
|
||||||
ircd::ctx::future<T>::get()
|
ircd::ctx::future<T>::get()
|
||||||
|
|
|
@ -147,10 +147,6 @@ ircd::ctx::promise<T>::set_value(T&& val)
|
||||||
st->val = std::move(val);
|
st->val = std::move(val);
|
||||||
st->finished = true;
|
st->finished = true;
|
||||||
st->cond.notify_all();
|
st->cond.notify_all();
|
||||||
if(st->callback) ircd::post([st(st)]
|
|
||||||
{
|
|
||||||
st->callback(st->eptr, st->val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -160,10 +156,6 @@ ircd::ctx::promise<void>::set_value()
|
||||||
assert(!finished());
|
assert(!finished());
|
||||||
st->finished = true;
|
st->finished = true;
|
||||||
st->cond.notify_all();
|
st->cond.notify_all();
|
||||||
if(st->callback) ircd::post([st(st)]
|
|
||||||
{
|
|
||||||
st->callback(st->eptr);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -175,10 +167,6 @@ ircd::ctx::promise<T>::set_value(const T &val)
|
||||||
st->val = val;
|
st->val = val;
|
||||||
st->finished = true;
|
st->finished = true;
|
||||||
st->cond.notify_all();
|
st->cond.notify_all();
|
||||||
if(st->callback) ircd::post([st(st)]
|
|
||||||
{
|
|
||||||
st->callback(st->eptr, st->val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -189,10 +177,6 @@ ircd::ctx::promise<void>::set_exception(std::exception_ptr eptr)
|
||||||
st->eptr = std::move(eptr);
|
st->eptr = std::move(eptr);
|
||||||
st->finished = true;
|
st->finished = true;
|
||||||
st->cond.notify_all();
|
st->cond.notify_all();
|
||||||
if(st->callback) ircd::post([st(st)]
|
|
||||||
{
|
|
||||||
st->callback(st->eptr);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -204,8 +188,4 @@ ircd::ctx::promise<T>::set_exception(std::exception_ptr eptr)
|
||||||
st->eptr = std::move(eptr);
|
st->eptr = std::move(eptr);
|
||||||
st->finished = true;
|
st->finished = true;
|
||||||
st->cond.notify_all();
|
st->cond.notify_all();
|
||||||
if(st->callback) ircd::post([st(st)]
|
|
||||||
{
|
|
||||||
st->callback(st->eptr, st->val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ struct ircd::ctx::shared_state
|
||||||
using reference_type = T &;
|
using reference_type = T &;
|
||||||
|
|
||||||
T val;
|
T val;
|
||||||
std::function<void (std::exception_ptr, T) noexcept> callback;
|
|
||||||
|
|
||||||
std::shared_ptr<const shared_state<T>> share() const;
|
std::shared_ptr<const shared_state<T>> share() const;
|
||||||
std::shared_ptr<shared_state<T>> share();
|
std::shared_ptr<shared_state<T>> share();
|
||||||
|
@ -49,8 +48,6 @@ struct ircd::ctx::shared_state<void>
|
||||||
{
|
{
|
||||||
using value_type = void;
|
using value_type = void;
|
||||||
|
|
||||||
std::function<void (std::exception_ptr) noexcept> callback;
|
|
||||||
|
|
||||||
std::shared_ptr<const shared_state<void>> share() const;
|
std::shared_ptr<const shared_state<void>> share() const;
|
||||||
std::shared_ptr<shared_state<void>> share();
|
std::shared_ptr<shared_state<void>> share();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue