0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 19:58:53 +02:00

ircd::ctx: Simplify queue interface; remove access to dock.

This commit is contained in:
Jason Volk 2018-12-28 12:42:08 -08:00
parent fe0f548496
commit c9c280c864

View file

@ -19,14 +19,11 @@ namespace ircd::ctx
template<class T>
class ircd::ctx::queue
{
struct dock dock;
dock d;
std::queue<T> q;
size_t w {0};
public:
explicit operator const struct dock &() const;
explicit operator struct dock &();
size_t empty() const;
size_t size() const;
size_t waiting() const;
@ -58,7 +55,7 @@ ircd::ctx::queue<T>::push(T&& t)
noexcept
{
q.push(std::forward<T>(t));
dock.notify();
d.notify();
}
template<class T>
@ -66,7 +63,7 @@ void
ircd::ctx::queue<T>::push(const T &t)
{
q.push(t);
dock.notify();
d.notify();
}
template<class T>
@ -75,7 +72,7 @@ void
ircd::ctx::queue<T>::emplace(args&&... a)
{
q.emplace(std::forward<args>(a)...);
dock.notify();
d.notify();
}
template<class T>
@ -88,7 +85,7 @@ ircd::ctx::queue<T>::pop()
--w;
}};
dock.wait([this]
d.wait([this]
{
return !q.empty();
});
@ -112,7 +109,7 @@ ircd::ctx::queue<T>::pop_for(const duration &dur)
const bool ready
{
dock.wait_for(dur, [this]
d.wait_for(dur, [this]
{
return !q.empty();
})
@ -140,7 +137,7 @@ ircd::ctx::queue<T>::pop_until(time_point&& tp)
const bool ready
{
dock.wait_until(tp, [this]
d.wait_until(tp, [this]
{
return !q.empty();
})
@ -178,18 +175,3 @@ const
{
return q.empty();
}
template<class T>
ircd::ctx::queue<T>::operator
struct dock &()
{
return dock;
}
template<class T>
ircd::ctx::queue<T>::operator
const struct dock &()
const
{
return dock;
}