mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 09:40:12 +01:00
ircd::ctx::latch: Minor rename; add explicit move semantic.
This commit is contained in:
parent
67e6c63580
commit
fea02ba300
1 changed files with 13 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue