0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::ctx: Move any renotifying to the ctx::dock itself.

This commit is contained in:
Jason Volk 2018-09-18 21:35:27 -07:00
parent 3b960d2576
commit be7a20d39a
2 changed files with 30 additions and 45 deletions

View file

@ -87,6 +87,11 @@ inline void
ircd::ctx::dock::wait()
{
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);
@ -104,6 +109,11 @@ ircd::ctx::dock::wait(predicate&& pred)
return;
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);
@ -124,6 +134,11 @@ ircd::ctx::dock::wait_for(const duration &dur)
static const duration zero(0);
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);
@ -146,6 +161,11 @@ ircd::ctx::dock::wait_for(const duration &dur,
return true;
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);
@ -173,6 +193,11 @@ bool
ircd::ctx::dock::wait_until(time_point&& tp)
{
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);
@ -193,6 +218,11 @@ ircd::ctx::dock::wait_until(time_point&& tp,
return true;
assert(current);
const unwind::exceptional renotify{[this]
{
notify_one();
}};
const unwind remove{[this]
{
q.remove(current);

View file

@ -76,7 +76,6 @@ ircd::ctx::queue<T>::emplace(args&&... a)
template<class T>
T
ircd::ctx::queue<T>::pop()
try
{
dock.wait([this]
{
@ -92,26 +91,11 @@ try
auto &ret(q.front());
return std::move(ret);
}
catch(const interrupted &)
{
if(!q.empty())
dock.notify();
throw;
}
catch(const terminated &)
{
if(!q.empty())
dock.notify();
throw;
}
template<class T>
template<class duration>
T
ircd::ctx::queue<T>::pop_for(const duration &dur)
try
{
const bool ready
{
@ -133,26 +117,11 @@ try
auto &ret(q.front());
return std::move(ret);
}
catch(const interrupted &)
{
if(!q.empty())
dock.notify();
throw;
}
catch(const terminated &)
{
if(!q.empty())
dock.notify();
throw;
}
template<class T>
template<class time_point>
T
ircd::ctx::queue<T>::pop_until(time_point&& tp)
try
{
const bool ready
{
@ -174,17 +143,3 @@ try
auto &ret(q.front());
return std::move(ret);
}
catch(const interrupted &)
{
if(!q.empty())
dock.notify();
throw;
}
catch(const terminated &)
{
if(!q.empty())
dock.notify();
throw;
}