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_THREAD_SAFE_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // performed the interface call. | 25 // performed the interface call. |
26 // | 26 // |
27 // To create a ThreadSafeInterfacePtr/ThreadSafeAssociatedInterfacePtr, first | 27 // To create a ThreadSafeInterfacePtr/ThreadSafeAssociatedInterfacePtr, first |
28 // create a regular InterfacePtr/AssociatedInterfacePtr that | 28 // create a regular InterfacePtr/AssociatedInterfacePtr that |
29 // you then provide to ThreadSafeInterfacePtr/AssociatedInterfacePtr::Create. | 29 // you then provide to ThreadSafeInterfacePtr/AssociatedInterfacePtr::Create. |
30 // You can then call methods on the | 30 // You can then call methods on the |
31 // ThreadSafeInterfacePtr/AssociatedInterfacePtr instance from any thread. | 31 // ThreadSafeInterfacePtr/AssociatedInterfacePtr instance from any thread. |
32 // | 32 // |
33 // Ex for ThreadSafeInterfacePtr: | 33 // Ex for ThreadSafeInterfacePtr: |
34 // frob::FrobinatorPtr frobinator; | 34 // frob::FrobinatorPtr frobinator; |
35 // frob::FrobinatorImpl impl(GetProxy(&frobinator)); | 35 // frob::FrobinatorImpl impl(MakeRequest(&frobinator)); |
36 // scoped_refptr<frob::ThreadSafeFrobinatorPtr> thread_safe_frobinator = | 36 // scoped_refptr<frob::ThreadSafeFrobinatorPtr> thread_safe_frobinator = |
37 // frob::ThreadSafeFrobinatorPtr::Create(std::move(frobinator)); | 37 // frob::ThreadSafeFrobinatorPtr::Create(std::move(frobinator)); |
38 // (*thread_safe_frobinator)->FrobinateToTheMax(); | 38 // (*thread_safe_frobinator)->FrobinateToTheMax(); |
39 // | 39 // |
40 // An alternate way is to create the ThreadSafeInterfacePtr unbound (not | 40 // An alternate way is to create the ThreadSafeInterfacePtr unbound (not |
41 // associated with an InterfacePtr) and call Bind() at a later time when the | 41 // associated with an InterfacePtr) and call Bind() at a later time when the |
42 // InterfacePtr becomes available. Note that you shouldn't call any interface | 42 // InterfacePtr becomes available. Note that you shouldn't call any interface |
43 // methods on the ThreadSafeInterfacePtr before it is bound. | 43 // methods on the ThreadSafeInterfacePtr before it is bound. |
44 | 44 |
45 template <typename Interface, template <typename> class InterfacePtrType> | 45 template <typename Interface, template <typename> class InterfacePtrType> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 using ThreadSafeAssociatedInterfacePtr = | 182 using ThreadSafeAssociatedInterfacePtr = |
183 ThreadSafeInterfacePtrBase<Interface, AssociatedInterfacePtr>; | 183 ThreadSafeInterfacePtrBase<Interface, AssociatedInterfacePtr>; |
184 | 184 |
185 template <typename Interface> | 185 template <typename Interface> |
186 using ThreadSafeInterfacePtr = | 186 using ThreadSafeInterfacePtr = |
187 ThreadSafeInterfacePtrBase<Interface, InterfacePtr>; | 187 ThreadSafeInterfacePtrBase<Interface, InterfacePtr>; |
188 | 188 |
189 } // namespace mojo | 189 } // namespace mojo |
190 | 190 |
191 #endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ | 191 #endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
OLD | NEW |