0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::ctx::dock: Add noexcept to interface observers.

ircd::ctx: Propagate noexcept on hot leafs;

ircd::ctx::list: Deinline size().
This commit is contained in:
Jason Volk 2019-09-10 10:19:50 -07:00
parent 1c5343be79
commit b6149b429e
5 changed files with 79 additions and 45 deletions

View file

@ -28,8 +28,8 @@ class ircd::ctx::dock
void notify(ctx &) noexcept;
public:
bool empty() const;
size_t size() const;
bool empty() const noexcept;
size_t size() const noexcept;
template<class time_point> bool wait_until(time_point&&, const predicate &);
template<class time_point> bool wait_until(time_point&&);

View file

@ -37,16 +37,16 @@ struct ircd::ctx::list
ctx *tail {nullptr};
// Get next or prev entry in ctx
static const ctx *next(const ctx *const &);
static const ctx *prev(const ctx *const &);
static ctx *&next(ctx *const &);
static ctx *&prev(ctx *const &);
static const ctx *next(const ctx *const &) noexcept;
static const ctx *prev(const ctx *const &) noexcept;
static ctx *&next(ctx *const &) noexcept;
static ctx *&prev(ctx *const &) noexcept;
public:
const ctx *front() const;
const ctx *back() const;
ctx *front();
ctx *back();
const ctx *front() const noexcept;
const ctx *back() const noexcept;
ctx *front() noexcept;
ctx *back() noexcept;
// iteration
bool for_each(const std::function<bool (const ctx &)> &) const;
@ -60,18 +60,18 @@ struct ircd::ctx::list
void rfor_each(const std::function<void (const ctx &)> &) const;
void rfor_each(const std::function<void (ctx &)> &);
bool empty() const;
size_t size() const;
bool empty() const noexcept;
size_t size() const noexcept;
void push_front(ctx *const & = current);
void push_back(ctx *const & = current);
void push(ctx *const & = current); // push_back
void push_front(ctx *const & = current) noexcept;
void push_back(ctx *const & = current) noexcept;
void push(ctx *const & = current) noexcept; // push_back
ctx *pop_front();
ctx *pop_back();
ctx *pop(); // pop_front
ctx *pop_front() noexcept;
ctx *pop_back() noexcept;
ctx *pop() noexcept; // pop_front
void remove(ctx *const & = current);
void remove(ctx *const & = current) noexcept;
list() = default;
list(list &&) noexcept;
@ -119,32 +119,21 @@ noexcept
inline ircd::ctx::ctx *
ircd::ctx::list::pop()
noexcept
{
return pop_front();
}
inline void
ircd::ctx::list::push(ctx *const &c)
noexcept
{
push_back(c);
}
inline size_t
ircd::ctx::list::size()
const
{
size_t i{0};
for_each([&i](const ctx &)
{
++i;
});
return i;
}
inline bool
ircd::ctx::list::empty()
const
const noexcept
{
assert((!head && !tail) || (head && tail));
return !head;
@ -152,26 +141,28 @@ const
inline ircd::ctx::ctx *
ircd::ctx::list::back()
noexcept
{
return tail;
}
inline ircd::ctx::ctx *
ircd::ctx::list::front()
noexcept
{
return head;
}
inline const ircd::ctx::ctx *
ircd::ctx::list::back()
const
const noexcept
{
return tail;
}
inline const ircd::ctx::ctx *
ircd::ctx::list::front()
const
const noexcept
{
return head;
}

View file

@ -27,17 +27,17 @@ class ircd::ctx::mutex
bool m;
public:
bool locked() const;
size_t waiting() const;
bool locked() const noexcept;
size_t waiting() const noexcept;
bool try_lock();
bool try_lock() noexcept;
template<class time_point> bool try_lock_until(const time_point &);
template<class duration> bool try_lock_for(const duration &);
void lock();
void unlock();
mutex();
mutex() noexcept;
mutex(mutex &&) noexcept;
mutex(const mutex &) = delete;
mutex &operator=(mutex &&) noexcept;
@ -47,6 +47,7 @@ class ircd::ctx::mutex
inline
ircd::ctx::mutex::mutex()
noexcept
:m{false}
{
}
@ -125,6 +126,7 @@ ircd::ctx::mutex::try_lock_until(const time_point &tp)
inline bool
ircd::ctx::mutex::try_lock()
noexcept
{
if(locked())
return false;
@ -135,14 +137,14 @@ ircd::ctx::mutex::try_lock()
inline size_t
ircd::ctx::mutex::waiting()
const
const noexcept
{
return q.size();
}
inline bool
ircd::ctx::mutex::locked()
const
const noexcept
{
return m;
}

View file

@ -751,6 +751,7 @@ noexcept
// uinterruptible
//
[[gnu::hot]]
ircd::ctx::this_ctx::uninterruptible::uninterruptible()
:theirs
{
@ -760,6 +761,7 @@ ircd::ctx::this_ctx::uninterruptible::uninterruptible()
interruptible(false);
}
[[gnu::hot]]
ircd::ctx::this_ctx::uninterruptible::~uninterruptible()
noexcept(false)
{
@ -770,6 +772,7 @@ noexcept(false)
// uninterruptible::nothrow
//
[[gnu::hot]]
ircd::ctx::this_ctx::uninterruptible::nothrow::nothrow()
noexcept
:theirs
@ -780,6 +783,7 @@ noexcept
interruptible(false, std::nothrow);
}
[[gnu::hot]]
ircd::ctx::this_ctx::uninterruptible::nothrow::~nothrow()
noexcept
{
@ -1006,6 +1010,7 @@ ircd::ctx::continuation::noop_interruptor{[]
// continuation
//
[[gnu::hot]]
ircd::ctx::continuation::continuation(const predicate &pred,
const interruptor &intr,
const yield_closure &closure)
@ -1083,6 +1088,7 @@ ircd::ctx::continuation::continuation(const predicate &pred,
}
}
[[gnu::hot]]
ircd::ctx::continuation::~continuation()
noexcept
{
@ -1105,6 +1111,7 @@ noexcept
// pointer while the context is awake.
}
[[gnu::hot]]
ircd::ctx::continuation::operator
boost::asio::yield_context &()
noexcept
@ -1114,6 +1121,7 @@ noexcept
return *self->yc;
}
[[gnu::hot]]
ircd::ctx::continuation::operator
const boost::asio::yield_context &()
const noexcept
@ -2705,7 +2713,7 @@ noexcept
/// The number of contexts waiting in the queue.
size_t
ircd::ctx::dock::size()
const
const noexcept
{
return q.size();
}
@ -2713,7 +2721,7 @@ const
/// The number of contexts waiting in the queue.
bool
ircd::ctx::dock::empty()
const
const noexcept
{
return q.empty();
}
@ -2723,8 +2731,10 @@ const
// ctx_list.h
//
[[gnu::hot]]
void
ircd::ctx::list::remove(ctx *const &c)
noexcept
{
assert(c);
@ -2747,8 +2757,10 @@ ircd::ctx::list::remove(ctx *const &c)
prev(c) = nullptr;
}
[[gnu::hot]]
ircd::ctx::ctx *
ircd::ctx::list::pop_back()
noexcept
{
const auto tail
{
@ -2778,8 +2790,10 @@ ircd::ctx::list::pop_back()
return tail;
}
[[gnu::hot]]
ircd::ctx::ctx *
ircd::ctx::list::pop_front()
noexcept
{
const auto head
{
@ -2809,8 +2823,10 @@ ircd::ctx::list::pop_front()
return head;
}
[[gnu::hot]]
void
ircd::ctx::list::push_front(ctx *const &c)
noexcept
{
assert(next(c) == nullptr);
assert(prev(c) == nullptr);
@ -2829,8 +2845,10 @@ ircd::ctx::list::push_front(ctx *const &c)
head = c;
}
[[gnu::hot]]
void
ircd::ctx::list::push_back(ctx *const &c)
noexcept
{
assert(next(c) == nullptr);
assert(prev(c) == nullptr);
@ -2849,6 +2867,19 @@ ircd::ctx::list::push_back(ctx *const &c)
tail = c;
}
size_t
ircd::ctx::list::size()
const noexcept
{
size_t i{0};
for_each([&i](const ctx &)
{
++i;
});
return i;
}
void
ircd::ctx::list::rfor_each(const std::function<void (ctx &)> &closure)
{
@ -2921,29 +2952,37 @@ const
return true;
}
[[gnu::hot]]
ircd::ctx::ctx *&
ircd::ctx::list::prev(ctx *const &c)
noexcept
{
assert(c);
return c->node.prev;
}
[[gnu::hot]]
ircd::ctx::ctx *&
ircd::ctx::list::next(ctx *const &c)
noexcept
{
assert(c);
return c->node.next;
}
[[gnu::hot]]
const ircd::ctx::ctx *
ircd::ctx::list::prev(const ctx *const &c)
noexcept
{
assert(c);
return c->node.prev;
}
[[gnu::hot]]
const ircd::ctx::ctx *
ircd::ctx::list::next(const ctx *const &c)
noexcept
{
assert(c);
return c->node.next;

View file

@ -5101,8 +5101,10 @@ console_cmd__net__host(opt &out, const string_view &line)
net::dns::resolve(hostport, opts, cbarr);
const ctx::uninterruptible ui;
while(!done)
dock.wait();
dock.wait([&done]
{
return done;
});
if(eptr)
std::rethrow_exception(eptr);