tesseract  4.0.0-1-g2a2b
ccutil.cpp
Go to the documentation of this file.
1 // Copyright 2008 Google Inc. All Rights Reserved.
2 // Author: scharron@google.com (Samuel Charron)
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 #include "ccutil.h"
14 
15 namespace tesseract {
17  params_(),
18 #ifdef _WIN32
19  STRING_INIT_MEMBER(tessedit_module_name, WINDLLNAME,
20  "Module colocated with tessdata dir", &params_),
21 #endif
22  INT_INIT_MEMBER(ambigs_debug_level, 0, "Debug level for unichar ambiguities",
23  &params_),
24  BOOL_MEMBER(use_definite_ambigs_for_classifier, 0, "Use definite"
25  " ambiguities when running character classifier", &params_),
26  BOOL_MEMBER(use_ambigs_for_adaption, 0, "Use ambigs for deciding"
27  " whether to adapt to a character", &params_) {
28 }
29 
30 // Destructor.
31 // It is defined here, so the compiler can create a single vtable
32 // instead of weak vtables in every compilation unit.
33 CCUtil::~CCUtil() = default;
34 
36 #ifdef _WIN32
37  mutex_ = CreateMutex(0, FALSE, 0);
38 #else
39  pthread_mutex_init(&mutex_, nullptr);
40 #endif
41 }
42 
44 #ifdef _WIN32
45  WaitForSingleObject(mutex_, INFINITE);
46 #else
47  pthread_mutex_lock(&mutex_);
48 #endif
49 }
50 
52 #ifdef _WIN32
53  ReleaseMutex(mutex_);
54 #else
55  pthread_mutex_unlock(&mutex_);
56 #endif
57 }
58 
59 CCUtilMutex tprintfMutex; // should remain global
60 } // namespace tesseract
#define STRING_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:306
#define INT_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:300
#define BOOL_MEMBER(name, val, comment, vec)
Definition: params.h:291
#define FALSE
Definition: capi.h:52
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:59