OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // A form of weak reference for use by CallOnMainThread (COMT). This | 7 // A form of weak reference for use by CallOnMainThread (COMT). This |
8 // class is essentially a thread-safe refcounted class that is used to | 8 // class is essentially a thread-safe refcounted class that is used to |
9 // hold pointers to resources that may "go away" due to the plugin | 9 // hold pointers to resources that may "go away" due to the plugin |
10 // instance being destroyed. Generally resource cleanup should be | 10 // instance being destroyed. Generally resource cleanup should be |
(...skipping 10 matching lines...) Expand all Loading... |
21 // destroys all resources associated with the queued callbacks. The | 21 // destroys all resources associated with the queued callbacks. The |
22 // WeakRef resource pointer is released, triggering the dtor for the | 22 // WeakRef resource pointer is released, triggering the dtor for the |
23 // resource, and the WeakRef reference is also decremented, so that | 23 // resource, and the WeakRef reference is also decremented, so that |
24 // when the COMT callback is invoked, it can discover that the | 24 // when the COMT callback is invoked, it can discover that the |
25 // associated callback data is gone, and will just abort by | 25 // associated callback data is gone, and will just abort by |
26 // decrementing the last reference to the WeakRef object. | 26 // decrementing the last reference to the WeakRef object. |
27 // | 27 // |
28 // In the normal execution, the callback data is present, and | 28 // In the normal execution, the callback data is present, and |
29 // ownership is released to the callback function. | 29 // ownership is released to the callback function. |
30 | 30 |
| 31 #ifndef NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_WEAK_REF_H_ |
| 32 #define NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_WEAK_REF_H_ |
| 33 |
31 #include <set> | 34 #include <set> |
32 | 35 |
33 #include "native_client/src/include/portability.h" | 36 #include "native_client/src/include/portability.h" |
34 #include "native_client/src/include/nacl_scoped_ptr.h" | 37 #include "native_client/src/include/nacl_scoped_ptr.h" |
35 #include "native_client/src/shared/platform/refcount_base.h" | 38 #include "native_client/src/shared/platform/refcount_base.h" |
36 #include "native_client/src/shared/platform/nacl_check.h" | 39 #include "native_client/src/shared/platform/nacl_check.h" |
37 #include "native_client/src/shared/platform/nacl_log.h" | 40 #include "native_client/src/shared/platform/nacl_log.h" |
38 #include "native_client/src/shared/platform/nacl_sync.h" | 41 #include "native_client/src/shared/platform/nacl_sync.h" |
39 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 42 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
40 | 43 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 WeakRef(WeakRefAnchor* anchor, R* resource) | 202 WeakRef(WeakRefAnchor* anchor, R* resource) |
200 : AnchoredResource(anchor), | 203 : AnchoredResource(anchor), |
201 resource_(resource) { | 204 resource_(resource) { |
202 CHECK(resource != NULL); | 205 CHECK(resource != NULL); |
203 } | 206 } |
204 | 207 |
205 scoped_ptr<R> resource_; // NULL when anchor object is destroyed. | 208 scoped_ptr<R> resource_; // NULL when anchor object is destroyed. |
206 }; | 209 }; |
207 | 210 |
208 } // namespace nacl | 211 } // namespace nacl |
| 212 |
| 213 #endif |
OLD | NEW |