mirror of
https://github.com/matrix-construct/construct
synced 2024-09-30 04:38:52 +02:00
ircd::ctx::queue: Simplify pops; universal push.
This commit is contained in:
parent
2e245dacd1
commit
592ad284f9
1 changed files with 17 additions and 26 deletions
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue