| 234 | } |
| 235 | |
| 236 | void Assign(T* ptr) { |
| 237 | if (IsValid()) { |
| 238 | if (ptr && ptr != kSentinelPointer) { |
| 239 | // Simply assign the pointer reusing the existing node. |
| 240 | SetValue(ptr); |
| 241 | this->CheckPointer(ptr); |
| 242 | return; |
| 243 | } |
| 244 | WeaknessPolicy::GetPersistentRegion(GetValue()).FreeNode(GetNode()); |
| 245 | SetNode(nullptr); |
| 246 | } |
| 247 | SetValue(ptr); |
| 248 | if (!IsValid()) return; |
| 249 | SetNode(WeaknessPolicy::GetPersistentRegion(GetValue()) |
| 250 | .AllocateNode(this, &BasicPersistent::Trace)); |
| 251 | this->CheckPointer(Get()); |
| 252 | } |
| 253 | |
| 254 | void ClearFromGC() const { |
| 255 | if (IsValid()) { |
no test coverage detected