Tools: Add a copyable SharedSemaphore

This commit is contained in:
Dennis Klein
2019-09-01 15:40:00 +02:00
committed by Dennis Klein
parent 0e5f648d2b
commit 5d6184cd1a
2 changed files with 42 additions and 1 deletions

View File

@@ -45,6 +45,29 @@ auto Semaphore::GetCount() -> std::size_t
return fCount;
}
SharedSemaphore::SharedSemaphore()
: fSemaphore(std::make_shared<Semaphore>())
{}
SharedSemaphore::SharedSemaphore(std::size_t initial_count)
: fSemaphore(std::make_shared<Semaphore>(initial_count))
{}
auto SharedSemaphore::Wait() -> void
{
fSemaphore->Wait();
}
auto SharedSemaphore::Signal() -> void
{
fSemaphore->Signal();
}
auto SharedSemaphore::GetCount() -> std::size_t
{
return fSemaphore->GetCount();
}
} /* namespace tools */
} /* namespace mq */
} /* namespace fair */