From 765ec46b91369bd76c764c98661fdcd9f5a699c0 Mon Sep 17 00:00:00 2001
From: Jason Volk <jason@zemos.net>
Date: Tue, 13 Aug 2019 20:43:46 -0700
Subject: [PATCH] ircd::ctx::promise: Inline trivial accessors; explicit bool
 operator.

---
 include/ircd/ctx/future.h  |  1 -
 include/ircd/ctx/promise.h | 54 ++++++++++++++++++++++++++++++++------
 ircd/ctx.cc                | 35 ------------------------
 3 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/include/ircd/ctx/future.h b/include/ircd/ctx/future.h
index a5e075c19..3aea34fb6 100644
--- a/include/ircd/ctx/future.h
+++ b/include/ircd/ctx/future.h
@@ -80,7 +80,6 @@ struct ircd::ctx::future<void>
 
 	bool valid() const                           { return !is(state(), future_state::INVALID);     }
 	bool operator!() const                       { return !valid();                                }
-	operator bool() const                        { return valid();                                 }
 
 	template<class U, class time_point> friend bool wait_until(const future<U> &, const time_point &, std::nothrow_t);
 	template<class U, class time_point> friend void wait_until(const future<U> &, const time_point &);
diff --git a/include/ircd/ctx/promise.h b/include/ircd/ctx/promise.h
index 0f2435366..040bf6c0d 100644
--- a/include/ircd/ctx/promise.h
+++ b/include/ircd/ctx/promise.h
@@ -47,18 +47,18 @@ struct ircd::ctx::promise_base
 	shared_state_base *st {nullptr};
 	mutable promise_base *next {nullptr};
 
-	template<class T> const shared_state<T> &state() const;
-	template<class T> shared_state<T> &state();
-	const shared_state_base &state() const;
-	shared_state_base &state();
+	template<class T> const shared_state<T> &state() const noexcept;
+	template<class T> shared_state<T> &state() noexcept;
+	const shared_state_base &state() const noexcept;
+	shared_state_base &state() noexcept;
 
 	void check_pending() const;
 	void make_ready();
 
   public:
-	bool valid() const;
-	operator bool() const;
-	bool operator!() const;
+	bool valid() const noexcept;
+	bool operator!() const noexcept;
+	explicit operator bool() const noexcept;
 
 	void set_exception(std::exception_ptr eptr);
 
@@ -172,9 +172,31 @@ const
 // promise_base
 //
 
+inline bool
+ircd::ctx::promise_base::operator!()
+const noexcept
+{
+	return !valid();
+}
+
+inline ircd::ctx::promise_base::operator
+bool()
+const noexcept
+{
+	return valid();
+}
+
+inline bool
+ircd::ctx::promise_base::valid()
+const noexcept
+{
+	return bool(st);
+}
+
 template<class T>
 ircd::ctx::shared_state<T> &
 ircd::ctx::promise_base::state()
+noexcept
 {
 	return static_cast<shared_state<T> &>(state());
 }
@@ -182,7 +204,23 @@ ircd::ctx::promise_base::state()
 template<class T>
 const ircd::ctx::shared_state<T> &
 ircd::ctx::promise_base::state()
-const
+const noexcept
 {
 	return static_cast<const shared_state<T> &>(state());
 }
+
+inline ircd::ctx::shared_state_base &
+ircd::ctx::promise_base::state()
+noexcept
+{
+	assert(valid());
+	return *st;
+}
+
+inline const ircd::ctx::shared_state_base &
+ircd::ctx::promise_base::state()
+const noexcept
+{
+	assert(valid());
+	return *st;
+}
diff --git a/ircd/ctx.cc b/ircd/ctx.cc
index 86d65470a..3be170ec1 100644
--- a/ircd/ctx.cc
+++ b/ircd/ctx.cc
@@ -2035,41 +2035,6 @@ const
 		throw promise_already_satisfied{};
 }
 
-bool
-ircd::ctx::promise_base::operator!()
-const
-{
-	return !valid();
-}
-
-ircd::ctx::promise_base::operator bool()
-const
-{
-	return valid();
-}
-
-bool
-ircd::ctx::promise_base::valid()
-const
-{
-	return bool(st);
-}
-
-ircd::ctx::shared_state_base &
-ircd::ctx::promise_base::state()
-{
-	assert(valid());
-	return *st;
-}
-
-const ircd::ctx::shared_state_base &
-ircd::ctx::promise_base::state()
-const
-{
-	assert(valid());
-	return *st;
-}
-
 /// Internal semantics; chases the linked list of promises and adds a reference
 /// to a new copy at the end (for copy semantic).
 void