• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2020 The Libphonenumber Authors
2 //
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 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // Author: Philippe Liard
16 
17 #ifndef I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_UNSAFE_H_
18 #define I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_UNSAFE_H_
19 
20 #include "phonenumbers/base/logging.h"
21 #include "phonenumbers/base/thread_checker.h"
22 
23 // Dummy lock implementation on non-POSIX platforms. If you are running on a
24 // different platform and care about thread-safety, please compile with
25 // -DI18N_PHONENUMBERS_USE_BOOST.
26 namespace i18n {
27 namespace phonenumbers {
28 
29 class Lock {
30  public:
Lock()31   Lock() {}
32 
Acquire()33   void Acquire() const {
34     DCHECK(thread_checker_.CalledOnValidThread());
35     IGNORE_UNUSED(thread_checker_);
36   }
37 
Release()38   void Release() const {
39     DCHECK(thread_checker_.CalledOnValidThread());
40     IGNORE_UNUSED(thread_checker_);
41   }
42 
43  private:
44   DISALLOW_COPY_AND_ASSIGN(Lock);
45   const ThreadChecker thread_checker_;
46 };
47 
48 }  // namespace phonenumbers
49 }  // namespace i18n
50 
51 #endif  // I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_UNSAFE_H_
52