Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::Semaphore Class Referencefinal

`#include <semaphore.h>`

## Public Member Functions
void | acquire ()
void | release (size_t n=1)
| Semaphore (int value=0)

## Detailed Description

Definition at line 16 of file semaphore.h.

## Constructor & Destructor Documentation

Botan::Semaphore::Semaphore | ( | int | value = `0` | ) |
| inline explicit

Definition at line 19 of file semaphore.h.

19 : m_value(value), m_wakeups(0) {}

## Member Function Documentation

void Botan::Semaphore::acquire | ( |  | ) |

Definition at line 28 of file semaphore.cpp.

29 {
30 std::unique_lock<std::mutex> lock(m_mutex);
31 if(m_value-- <= 0)
32 {
33 m_cond.wait(lock, [this] { return m_wakeups > 0; });
34 --m_wakeups;
35 }
36 }

void Botan::Semaphore::release | ( | size_t | n = `1` | ) |

Definition at line 14 of file semaphore.cpp.

15 {
16 for(size_t i = 0; i != n; ++i)
17 {
18 std::lock_guard<std::mutex> lock(m_mutex);
19
20 if(m_value++ < 0)
21 {
22 ++m_wakeups;
23 m_cond.notify_one();
24 }
25 }
26 }

The documentation for this class was generated from the following files:

- src/lib/utils/thread_utils/semaphore.h
- src/lib/utils/thread_utils/semaphore.cpp