kaldi-semaphore.h
Go to the documentation of this file.
1 // util/kaldi-semaphore.h
2 
3 // Copyright 2012 Karel Vesely (Brno University of Technology)
4 // 2017 Dogan Can (University of Southern California)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 
22 #ifndef KALDI_THREAD_KALDI_SEMAPHORE_H_
23 #define KALDI_THREAD_KALDI_SEMAPHORE_H_ 1
24 
25 #include <mutex>
26 #include <condition_variable>
27 
28 namespace kaldi {
29 
30 class Semaphore {
31  public:
32  Semaphore(int32 count = 0);
33 
34  ~Semaphore();
35 
36  bool TryWait();
37  void Wait();
38  void Signal();
39 
40  private:
42 
43  std::mutex mutex_;
44  std::condition_variable condition_variable_;
46 };
47 
48 } //namespace
49 
50 #endif // KALDI_THREAD_KALDI_SEMAPHORE_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Signal()
increase the counter
kaldi::int32 int32
Semaphore(int32 count=0)
bool TryWait()
Returns true if Wait() goes through.
const size_t count
int32 count_
the semaphore counter, 0 means block on Wait()
KALDI_DISALLOW_COPY_AND_ASSIGN(Semaphore)
std::condition_variable condition_variable_
void Wait()
decrease the counter