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

Side by Side Diff: third_party/WebKit/Source/platform/heap/BlinkGCAPIReference.md

Issue 1458403002: Oilpan: Mention pre-finalizer registration in the documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Blink GC API reference 1 # Blink GC API reference
2 2
3 This document is work in progress. 3 This document is work in progress.
4 4
5 [TOC] 5 [TOC]
6 6
7 ## Header file 7 ## Header file
8 8
9 Unless otherwise noted, any of the primitives explained in this page requires th e following `#include` statement: 9 Unless otherwise noted, any of the primitives explained in this page requires th e following `#include` statement:
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 `USING_PRE_FINALIZER(ClassName, functionName)` in a class declaration declares t he class has a *pre-finalizer* of name 91 `USING_PRE_FINALIZER(ClassName, functionName)` in a class declaration declares t he class has a *pre-finalizer* of name
92 `functionName`. 92 `functionName`.
93 93
94 A pre-finalizer is a user-defined member function of a garbage-collected class t hat is called when the object is going 94 A pre-finalizer is a user-defined member function of a garbage-collected class t hat is called when the object is going
95 to be swept but before the garbage collector actually sweeps any objects. Theref ore, it is allowed for a pre-finalizer 95 to be swept but before the garbage collector actually sweeps any objects. Theref ore, it is allowed for a pre-finalizer
96 to touch any other on-heap objects, while a destructor is not. It is useful for doing some cleanups that cannot be done 96 to touch any other on-heap objects, while a destructor is not. It is useful for doing some cleanups that cannot be done
97 with a destructor. 97 with a destructor.
98 98
99 A pre-finalizer must have the following function signature: `void preFinalizer() `. You can change the function name. 99 A pre-finalizer must have the following function signature: `void preFinalizer() `. You can change the function name.
100 100
101 A pre-finalizer must be registered in the constructor by using the following sta tement:
102 "`ThreadState::current()->registerPreFinalizer(this, preFinalizerName);`".
103
101 ```c++ 104 ```c++
102 class YourClass : public GarbageCollectedFinalized<YourClass> { 105 class YourClass : public GarbageCollectedFinalized<YourClass> {
103 USING_PRE_FINALIZER(YourClass, dispose); 106 USING_PRE_FINALIZER(YourClass, dispose);
104 public: 107 public:
108 YourClass()
109 {
110 ThreadState::current()->registerPreFinalizer(this, dispose);
sof 2015/11/21 16:11:36 ThreadState::registerPreFinalizer() doesn't take t
Yuta Kitamura 2015/11/24 07:07:59 Whoops, thanks. I'll follow-up with this. (Commen
111 }
105 void dispose() 112 void dispose()
106 { 113 {
107 m_other->dispose(); // OK; you can touch other on-heap objects in a pre- finalizer. 114 m_other->dispose(); // OK; you can touch other on-heap objects in a pre- finalizer.
108 } 115 }
109 ~YourClass() 116 ~YourClass()
110 { 117 {
111 // m_other->dispose(); // BAD. 118 // m_other->dispose(); // BAD.
112 } 119 }
113 120
114 private: 121 private:
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 DEFINE_TRACE(C) 311 DEFINE_TRACE(C)
305 { 312 {
306 visitor->trace(m_x); 313 visitor->trace(m_x);
307 visitor->trace(m_y); // Weak member needs to be traced. 314 visitor->trace(m_y); // Weak member needs to be traced.
308 visitor->trace(m_z); // Heap collection does, too. 315 visitor->trace(m_z); // Heap collection does, too.
309 B::trace(visitor); // Delegate to the parent. In this case it's empty, but t his is required. 316 B::trace(visitor); // Delegate to the parent. In this case it's empty, but t his is required.
310 } 317 }
311 ``` 318 ```
312 319
313 ## Heap collections 320 ## Heap collections
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698