Commit 35c941e4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Check for max value in test semaphore

Summary: [Folly] Check for max value in test semaphore, beyond which posts cannot be tolerated.

Reviewed By: aary

Differential Revision: D15938166

fbshipit-source-id: 1f3fee97a9662dafc5b434c0449831147aa3c976
parent 093067ce
......@@ -77,6 +77,9 @@ class Semaphore {
template <typename PrePost>
void post(PrePost pre_post) {
std::unique_lock<std::mutex> l{m_};
if (value_ == -size_t(1)) {
throw_exception<std::logic_error>("overflow");
}
pre_post();
if (!waiting_) {
++value_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment