0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-01 00:08:22 +02:00

ircd::ctx::latch: Minor rename; add explicit move semantic.

This commit is contained in:
Jason Volk 2018-11-13 18:30:40 -08:00
parent 67e6c63580
commit fea02ba300

View file

@ -18,7 +18,7 @@ namespace ircd::ctx
class ircd::ctx::latch
{
mutable struct dock dock;
mutable dock d;
size_t count {0};
public:
@ -29,7 +29,7 @@ class ircd::ctx::latch
latch(const size_t &count);
latch() = default;
latch(latch &&) = default;
latch(latch &&);
latch(const latch &) = delete;
~latch() noexcept;
};
@ -39,6 +39,14 @@ ircd::ctx::latch::latch(const size_t &count)
:count{count}
{}
inline
ircd::ctx::latch::latch(latch &&o)
:d{std::move(o.d)}
,count{std::move(o.count)}
{
o.count = 0;
}
inline
ircd::ctx::latch::~latch()
noexcept
@ -50,7 +58,7 @@ inline void
ircd::ctx::latch::wait()
const
{
dock.wait([this]
d.wait([this]
{
return is_ready();
});
@ -60,7 +68,7 @@ inline void
ircd::ctx::latch::count_down_and_wait()
{
if(--count == 0)
dock.notify_all();
d.notify_all();
else
wait();
}
@ -70,7 +78,7 @@ ircd::ctx::latch::count_down(const size_t &n)
{
count -= n;
if(is_ready())
dock.notify_all();
d.notify_all();
}