OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 #ifndef REF_COUNT_H_ | 4 #ifndef GTEST_PPAPI_REF_COUNT_H_ |
5 #define REF_COUNT_H_ | 5 #define GTEST_PPAPI_REF_COUNT_H_ |
6 | 6 |
7 #include "c_salt/threading/pthread_ext.h" | 7 #include "gtest_ppapi/pthread_ext.h" |
8 | |
9 namespace threading { | |
10 | 8 |
11 // A thread-safe reference counter for class CompletionCallbackFactory. | 9 // A thread-safe reference counter for class CompletionCallbackFactory. |
12 class RefCount { | 10 class RefCount { |
13 public: | 11 public: |
14 RefCount() : ref_(0) { | 12 RefCount() : ref_(0) { |
15 pthread_mutex_init(&mutex_, NULL); | 13 pthread_mutex_init(&mutex_, NULL); |
16 } | 14 } |
17 ~RefCount() { | 15 ~RefCount() { |
18 pthread_mutex_destroy(&mutex_); | 16 pthread_mutex_destroy(&mutex_); |
19 } | 17 } |
(...skipping 14 matching lines...) Expand all Loading... |
34 pthread_mutex_unlock(&mutex_); | 32 pthread_mutex_unlock(&mutex_); |
35 } | 33 } |
36 return ret_val; | 34 return ret_val; |
37 } | 35 } |
38 | 36 |
39 private: | 37 private: |
40 int32_t ref_; | 38 int32_t ref_; |
41 pthread_mutex_t mutex_; | 39 pthread_mutex_t mutex_; |
42 }; | 40 }; |
43 | 41 |
44 } // namespace threading | 42 #endif // GTEST_PPAPI_REF_COUNT_H_ |
45 #endif // REF_COUNT_H_ | |
46 | |
OLD | NEW |