#include <kaldi-semaphore.h>
Public Member Functions | |
Semaphore (int32 count=0) | |
~Semaphore () | |
bool | TryWait () |
Returns true if Wait() goes through. More... | |
void | Wait () |
decrease the counter More... | |
void | Signal () |
increase the counter More... | |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (Semaphore) | |
Private Attributes | |
int32 | count_ |
the semaphore counter, 0 means block on Wait() More... | |
std::mutex | mutex_ |
std::condition_variable | condition_variable_ |
Definition at line 30 of file kaldi-semaphore.h.
Definition at line 28 of file kaldi-semaphore.cc.
References count, Semaphore::count_, and KALDI_ASSERT.
~Semaphore | ( | ) |
Definition at line 33 of file kaldi-semaphore.cc.
|
private |
void Signal | ( | ) |
increase the counter
Definition at line 51 of file kaldi-semaphore.cc.
References Semaphore::condition_variable_, Semaphore::count_, and Semaphore::mutex_.
Referenced by DiscriminativeExamplesRepository::AcceptExample(), NnetBatchInference::AcceptInput(), NnetBatchDecoder::AcceptInput(), NnetBatchDecoder::Decode(), DiscriminativeExamplesRepository::ExamplesDone(), NnetBatchInference::Finished(), NnetBatchDecoder::Finished(), NnetExampleBackgroundReader::GetNextMinibatch(), NnetExampleBackgroundReader::NnetExampleBackgroundReader(), DiscriminativeExamplesRepository::ProvideExample(), NnetExampleBackgroundReader::ReadExamples(), TaskSequencer< C >::RunTask(), ThreadSynchronizer::SetAbort(), ThreadSynchronizer::ThreadSynchronizer(), and ThreadSynchronizer::UnlockSuccess().
bool TryWait | ( | ) |
Returns true if Wait() goes through.
Definition at line 35 of file kaldi-semaphore.cc.
References Semaphore::count_, and Semaphore::mutex_.
Referenced by NnetBatchInference::GetOutput().
void Wait | ( | ) |
decrease the counter
Definition at line 44 of file kaldi-semaphore.cc.
References Semaphore::condition_variable_, Semaphore::count_, and Semaphore::mutex_.
Referenced by DiscriminativeExamplesRepository::AcceptExample(), NnetBatchDecoder::AcceptInput(), NnetBatchInference::Compute(), NnetBatchDecoder::Compute(), NnetBatchDecoder::Decode(), DiscriminativeExamplesRepository::ExamplesDone(), NnetExampleBackgroundReader::GetNextMinibatch(), NnetBatchInference::GetOutput(), ThreadSynchronizer::Lock(), DiscriminativeExamplesRepository::ProvideExample(), and NnetExampleBackgroundReader::ReadExamples().
|
private |
Definition at line 44 of file kaldi-semaphore.h.
Referenced by Semaphore::Signal(), and Semaphore::Wait().
|
private |
the semaphore counter, 0 means block on Wait()
Definition at line 41 of file kaldi-semaphore.h.
Referenced by Semaphore::Semaphore(), Semaphore::Signal(), Semaphore::TryWait(), and Semaphore::Wait().
|
private |
Definition at line 43 of file kaldi-semaphore.h.
Referenced by Semaphore::Signal(), Semaphore::TryWait(), and Semaphore::Wait().