0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 20:28:52 +02:00

ircd::ctx::queue: Simplify pops; universal push.

This commit is contained in:
Jason Volk 2018-09-18 23:51:43 -07:00
parent 2e245dacd1
commit 592ad284f9

View file

@ -49,10 +49,10 @@ noexcept
template<class T> template<class T>
void void
ircd::ctx::queue<T>::push(T &&t) ircd::ctx::queue<T>::push(T&& t)
noexcept noexcept
{ {
q.push(std::move(t)); q.push(std::forward<T>(t));
dock.notify(); dock.notify();
} }
@ -82,14 +82,11 @@ ircd::ctx::queue<T>::pop()
return !q.empty(); return !q.empty();
}); });
const unwind pop([this] assert(!q.empty());
{ const unwind::nominal::assertion una;
assert(!q.empty()); auto ret(std::move(q.front()));
q.pop(); q.pop();
}); return ret;
auto &ret(q.front());
return std::move(ret);
} }
template<class T> template<class T>
@ -108,14 +105,11 @@ ircd::ctx::queue<T>::pop_for(const duration &dur)
if(!ready) if(!ready)
throw timeout{}; throw timeout{};
const unwind pop([this] assert(!q.empty());
{ const unwind::nominal::assertion una;
assert(!q.empty()); auto ret(std::move(q.front()));
q.pop(); q.pop();
}); return ret;
auto &ret(q.front());
return std::move(ret);
} }
template<class T> template<class T>
@ -134,12 +128,9 @@ ircd::ctx::queue<T>::pop_until(time_point&& tp)
if(!ready) if(!ready)
throw timeout{}; throw timeout{};
const unwind pop([this] assert(!q.empty());
{ const unwind::nominal::assertion una;
assert(!q.empty()); auto ret(std::move(q.front()));
q.pop(); q.pop();
}); return ret;
auto &ret(q.front());
return std::move(ret);
} }