0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::ctx::dock: Add query to find if ctx is waiting on dock.

This commit is contained in:
Jason Volk 2019-09-10 10:42:55 -07:00
parent efdc626495
commit ba11205f2c
2 changed files with 15 additions and 0 deletions

View file

@ -30,6 +30,7 @@ class ircd::ctx::dock
public:
bool empty() const noexcept;
size_t size() const noexcept;
bool waiting(const ctx &) const noexcept;
template<class time_point> bool wait_until(time_point&&, const predicate &);
template<class time_point> bool wait_until(time_point&&);

View file

@ -2710,6 +2710,20 @@ noexcept
ircd::ctx::notify(ctx);
}
/// The number of contexts waiting in the queue.
bool
ircd::ctx::dock::waiting(const ctx &a)
const noexcept
{
// for_each returns false if a was found
return !q.for_each(list::closure_bool_const{[&a]
(const ctx &b)
{
// return false to break on equal
return std::addressof(a) != std::addressof(b);
}});
}
/// The number of contexts waiting in the queue.
size_t
ircd::ctx::dock::size()