Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: mojo/edk/util/ref_counted.h

Issue 1423713009: EDK: Move ref counting classes to mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | mojo/edk/util/ref_counted_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // Provides a base class for reference-counted classes. 5 // Provides a base class for reference-counted classes.
6 6
7 #ifndef MOJO_EDK_SYSTEM_REF_COUNTED_H_ 7 #ifndef MOJO_EDK_UTIL_REF_COUNTED_H_
8 #define MOJO_EDK_SYSTEM_REF_COUNTED_H_ 8 #define MOJO_EDK_UTIL_REF_COUNTED_H_
9 9
10 #include <assert.h> 10 #include <assert.h>
11 11
12 #include <cstddef> 12 #include <cstddef>
13 #include <utility> 13 #include <utility>
14 14
15 #include "mojo/edk/system/ref_counted_internal.h" 15 #include "mojo/edk/util/ref_counted_internal.h"
16 #include "mojo/edk/system/ref_ptr.h" 16 #include "mojo/edk/util/ref_ptr.h"
17 #include "mojo/public/cpp/system/macros.h" 17 #include "mojo/public/cpp/system/macros.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace system { 20 namespace util {
21 21
22 // A base class for (thread-safe) reference-counted classes. Use like: 22 // A base class for (thread-safe) reference-counted classes. Use like:
23 // 23 //
24 // class Foo : public RefCountedThreadSafe<Foo> { 24 // class Foo : public RefCountedThreadSafe<Foo> {
25 // ... 25 // ...
26 // }; 26 // };
27 // 27 //
28 // |~Foo()| *may* be made private (e.g., to avoid accidental deletion of objects 28 // |~Foo()| *may* be made private (e.g., to avoid accidental deletion of objects
29 // while there are still references to them), |Foo| should friend 29 // while there are still references to them), |Foo| should friend
30 // |RefCountedThreadSafe<Foo>|; use |FRIEND_REF_COUNTED_THREAD_SAFE()| for this: 30 // |RefCountedThreadSafe<Foo>|; use |FRIEND_REF_COUNTED_THREAD_SAFE()| for this:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // and also writing one's own ref pointer class impossible. 102 // and also writing one's own ref pointer class impossible.
103 void Adopt() { internal::RefCountedThreadSafeBase::Adopt(); } 103 void Adopt() { internal::RefCountedThreadSafeBase::Adopt(); }
104 #endif 104 #endif
105 105
106 MOJO_DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe); 106 MOJO_DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
107 }; 107 };
108 108
109 // If you subclass |RefCountedThreadSafe| and want to keep your destructor 109 // If you subclass |RefCountedThreadSafe| and want to keep your destructor
110 // private, use this. (See the example above |RefCountedThreadSafe|.) 110 // private, use this. (See the example above |RefCountedThreadSafe|.)
111 #define FRIEND_REF_COUNTED_THREAD_SAFE(T) \ 111 #define FRIEND_REF_COUNTED_THREAD_SAFE(T) \
112 friend class ::mojo::system::RefCountedThreadSafe<T> 112 friend class ::mojo::util::RefCountedThreadSafe<T>
113 113
114 // If you want to keep your constructor(s) private and still want to use 114 // If you want to keep your constructor(s) private and still want to use
115 // |MakeRefCounted<T>()|, use this. (See the example above 115 // |MakeRefCounted<T>()|, use this. (See the example above
116 // |RefCountedThreadSafe|.) 116 // |RefCountedThreadSafe|.)
117 #define FRIEND_MAKE_REF_COUNTED(T) \ 117 #define FRIEND_MAKE_REF_COUNTED(T) \
118 friend class ::mojo::system::internal::MakeRefCountedHelper<T> 118 friend class ::mojo::util::internal::MakeRefCountedHelper<T>
119 119
120 } // namespace system 120 } // namespace util
121 } // namespace mojo 121 } // namespace mojo
122 122
123 #endif // MOJO_EDK_SYSTEM_REF_COUNTED_H_ 123 #endif // MOJO_EDK_UTIL_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | mojo/edk/util/ref_counted_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698