OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 4 |
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "mojo/public/cpp/bindings/bindings_export.h" | 14 #include "mojo/public/cpp/bindings/bindings_export.h" |
15 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/core.h" |
| 16 #include "mojo/public/cpp/system/wait_set.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 | 19 |
19 // SyncHandleRegistry is a thread-local storage to register handles that want to | 20 // SyncHandleRegistry is a thread-local storage to register handles that want to |
20 // be watched together. | 21 // be watched together. |
21 // | 22 // |
22 // This class is not thread safe. | 23 // This class is not thread safe. |
23 class MOJO_CPP_BINDINGS_EXPORT SyncHandleRegistry | 24 class MOJO_CPP_BINDINGS_EXPORT SyncHandleRegistry |
24 : public base::RefCounted<SyncHandleRegistry> { | 25 : public base::RefCounted<SyncHandleRegistry> { |
25 public: | 26 public: |
(...skipping 22 matching lines...) Expand all Loading... |
48 return std::hash<uint32_t>()(static_cast<uint32_t>(handle.value())); | 49 return std::hash<uint32_t>()(static_cast<uint32_t>(handle.value())); |
49 } | 50 } |
50 }; | 51 }; |
51 using HandleMap = std::unordered_map<Handle, HandleCallback, HandleHasher>; | 52 using HandleMap = std::unordered_map<Handle, HandleCallback, HandleHasher>; |
52 | 53 |
53 SyncHandleRegistry(); | 54 SyncHandleRegistry(); |
54 ~SyncHandleRegistry(); | 55 ~SyncHandleRegistry(); |
55 | 56 |
56 HandleMap handles_; | 57 HandleMap handles_; |
57 | 58 |
58 ScopedHandle wait_set_handle_; | 59 WaitSet wait_set_; |
59 | 60 |
60 base::ThreadChecker thread_checker_; | 61 base::ThreadChecker thread_checker_; |
61 | 62 |
62 DISALLOW_COPY_AND_ASSIGN(SyncHandleRegistry); | 63 DISALLOW_COPY_AND_ASSIGN(SyncHandleRegistry); |
63 }; | 64 }; |
64 | 65 |
65 } // namespace mojo | 66 } // namespace mojo |
66 | 67 |
67 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ | 68 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_HANDLE_REGISTRY_H_ |
OLD | NEW |