OLD | NEW |
1 # Blink GC API reference | 1 # Blink GC API reference |
2 | 2 |
3 This is a through document for Oilpan API usage. | 3 This is a through document for Oilpan API usage. |
4 If you want to learn the API usage quickly, look at | 4 If you want to learn the API usage quickly, look at |
5 [this tutorial](https://docs.google.com/presentation/d/1XPu03ymz8W295mCftEC9KshH
9Icxfq81YwIJQzQrvxo/edit#slide=id.p). | 5 [this tutorial](https://docs.google.com/presentation/d/1XPu03ymz8W295mCftEC9KshH
9Icxfq81YwIJQzQrvxo/edit#slide=id.p). |
6 | 6 |
7 [TOC] | 7 [TOC] |
8 | 8 |
9 ## Header file | 9 ## Header file |
10 | 10 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 ```c++ | 225 ```c++ |
226 void someFunction() | 226 void someFunction() |
227 { | 227 { |
228 SomeGarbageCollectedClass* object = new SomeGarbageCollectedClass; // OK, re
tained by a pointer. | 228 SomeGarbageCollectedClass* object = new SomeGarbageCollectedClass; // OK, re
tained by a pointer. |
229 ... | 229 ... |
230 } | 230 } |
231 // OK to leave the object behind. The Blink GC system will free it up when it be
comes unused. | 231 // OK to leave the object behind. The Blink GC system will free it up when it be
comes unused. |
232 ``` | 232 ``` |
233 | 233 |
234 *** aside | |
235 *Transitional only* | |
236 | |
237 `RawPtr<T>` is a simple wrapper of a raw pointer `T*` used in the transitional p
eriod. | |
238 Most`RawPtr<T>`s will be replaced with raw pointers. | |
239 | |
240 ### Member, WeakMember | 234 ### Member, WeakMember |
241 | 235 |
242 In a garbage-collected class, on-heap objects must be retained by `Member<T>` or
`WeakMember<T>`, depending on | 236 In a garbage-collected class, on-heap objects must be retained by `Member<T>` or
`WeakMember<T>`, depending on |
243 the desired semantics. | 237 the desired semantics. |
244 | 238 |
245 `Member<T>` represents a *strong* reference to an object of type `T`, which mean
s that the referred object is kept | 239 `Member<T>` represents a *strong* reference to an object of type `T`, which mean
s that the referred object is kept |
246 alive as long as the owner class instance is alive. Unlike `RefPtr<T>`, it is ok
ay to form a reference cycle with | 240 alive as long as the owner class instance is alive. Unlike `RefPtr<T>`, it is ok
ay to form a reference cycle with |
247 members (in on-heap objects) and raw pointers (on stack). | 241 members (in on-heap objects) and raw pointers (on stack). |
248 | 242 |
249 `WeakMember<T>` is a *weak* reference to an object of type `T`. Unlike `Member<T
>`, `WeakMember<T>` does not keep | 243 `WeakMember<T>` is a *weak* reference to an object of type `T`. Unlike `Member<T
>`, `WeakMember<T>` does not keep |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 DEFINE_TRACE(C) | 376 DEFINE_TRACE(C) |
383 { | 377 { |
384 visitor->trace(m_x); | 378 visitor->trace(m_x); |
385 visitor->trace(m_y); // Weak member needs to be traced. | 379 visitor->trace(m_y); // Weak member needs to be traced. |
386 visitor->trace(m_z); // Heap collection does, too. | 380 visitor->trace(m_z); // Heap collection does, too. |
387 B::trace(visitor); // Delegate to the parent. In this case it's empty, but t
his is required. | 381 B::trace(visitor); // Delegate to the parent. In this case it's empty, but t
his is required. |
388 } | 382 } |
389 ``` | 383 ``` |
390 | 384 |
391 ## Heap collections | 385 ## Heap collections |
OLD | NEW |