Initial Commit

This commit is contained in:
Norman Lansing
2026-01-28 19:08:51 -05:00
commit ecb33115bf
54042 changed files with 9695586 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#include <chrono>
#include "countdownlatch.hpp"
clatch::countdownlatch::countdownlatch(uint32_t count) {
this->count = count;
}
void clatch::countdownlatch::await(uint64_t nanosecs) {
std::unique_lock<std::mutex> lck(lock);
if (0 == count){
return;
}
if (nanosecs > 0) {
cv.wait_for(lck, std::chrono::nanoseconds(nanosecs));
} else {
cv.wait(lck);
}
}
uint32_t clatch::countdownlatch::get_count() {
std::unique_lock<std::mutex> lck(lock);
return count;
}
void clatch::countdownlatch::count_down() {
std::unique_lock<std::mutex> lck(lock);
if (0 == count) {
return;
}
--count;
if (0 == count) {
cv.notify_all();
}
}