mirror of
https://github.com/netchx/netch.git
synced 2026-03-30 19:09:48 +08:00
[RouteHelper] Add WaitForUnicastIP
This commit is contained in:
19
RouteHelper/WaitGroup.cpp
Normal file
19
RouteHelper/WaitGroup.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "WaitGroup.h"
|
||||
|
||||
void WaitGroup::Add(int size)
|
||||
{
|
||||
this->counter += size;
|
||||
}
|
||||
|
||||
void WaitGroup::Done()
|
||||
{
|
||||
if (--this->counter <= 0)
|
||||
this->condition.notify_all();
|
||||
}
|
||||
|
||||
void WaitGroup::Wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(this->mutex);
|
||||
|
||||
condition.wait(lock, [&] { return counter <= 0; });
|
||||
}
|
||||
Reference in New Issue
Block a user