All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
opdet::opDetDigitizerWorker::Semaphore Class Reference

#include <opDetDigitizerWorker.hh>

Public Member Functions

 Semaphore (unsigned count_=0)
 
void increment (unsigned n=1)
 
void decrement (unsigned n=1)
 

Private Attributes

std::mutex mtx
 
std::condition_variable cv
 
unsigned count
 

Detailed Description

Definition at line 52 of file opDetDigitizerWorker.hh.

Constructor & Destructor Documentation

opdet::opDetDigitizerWorker::Semaphore::Semaphore ( unsigned  count_ = 0)
inline

Definition at line 54 of file opDetDigitizerWorker.hh.

Member Function Documentation

void opdet::opDetDigitizerWorker::Semaphore::decrement ( unsigned  n = 1)

Definition at line 68 of file opDetDigitizerWorker.cc.

69 {
70  std::unique_lock<std::mutex> lock(mtx);
71 
72  while (count < n) {
73  cv.wait(lock);
74  }
75  count -= n;
76 }
void opdet::opDetDigitizerWorker::Semaphore::increment ( unsigned  n = 1)

Definition at line 61 of file opDetDigitizerWorker.cc.

62 {
63  std::unique_lock<std::mutex> lock(mtx);
64  count += n;
65  cv.notify_all();
66 }

Member Data Documentation

unsigned opdet::opDetDigitizerWorker::Semaphore::count
private

Definition at line 61 of file opDetDigitizerWorker.hh.

std::condition_variable opdet::opDetDigitizerWorker::Semaphore::cv
private

Definition at line 60 of file opDetDigitizerWorker.hh.

std::mutex opdet::opDetDigitizerWorker::Semaphore::mtx
private

Definition at line 59 of file opDetDigitizerWorker.hh.


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