90 std::unique_lock<std::mutex> uk(count_mtx);
92 this->capacity_ = val;
130 std::unique_lock<std::mutex> uk(count_mtx);
132 if (++acquired_ == capacity_)
154 std::unique_lock<std::mutex> uk(count_mtx);
156 if (acquired_ == capacity_)
160 if (++acquired_ >= capacity_)
161 return mtx.try_lock();
176 std::unique_lock<std::mutex> uk(count_mtx);
178 if (acquired_ != 0 && --acquired_ == capacity_ - 1)
185 #include <samchon/library/UniqueAcquire.hpp> 186 #include <samchon/library/SharedAcquire.hpp> auto acquired() const -> size_t
Get acquired size.
void setCapacity(size_t val)
Set size.
size_t acquired_
Acquired count.
Semaphore(size_t capacity=2)
void acquire()
Acquire admission.
auto capacity() const -> size_t
Get size.
size_t capacity_
The size.
auto tryAcquire() -> bool
Try to acquire admission.
void release()
Release an admission.