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

Unified Diff: include/v8.h

Issue 15023010: Add Persistent::ClearAndLeak. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Code review (svenpanne) Created 7 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 3a86e86e020cbc9448c50f2ccd21476035a66c2e..0fe03ef81430cb6b5730511ec7b66a1234582adf 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -695,6 +695,16 @@ template <class T> class Persistent // NOLINT
*/
V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other));
+ /**
+ * Returns the underlying raw pointer and clears the handle. The caller is
+ * responsible of eventually destroying the underlying object (by creating a
+ * Persistent handle which points to it and Disposing it). In the future,
+ * destructing a Persistent will also Dispose it. With this function, the
+ * embedder can let the Persistent go out of scope without it getting
+ * disposed.
+ */
+ V8_INLINE(T* ClearAndLeak());
+
#ifndef V8_USE_UNSAFE_HANDLES
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
@@ -5384,6 +5394,7 @@ void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
SetWrapperClassId(Isolate::GetCurrent(), class_id);
}
+
template <class T>
void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) {
Dispose(isolate);
@@ -5400,6 +5411,21 @@ void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) {
#endif
}
+
+template <class T>
+T* Persistent<T>::ClearAndLeak() {
+ T* old;
+#ifdef V8_USE_UNSAFE_HANDLES
+ old = **this;
+ *this = Persistent<T>();
+#else
+ old = val_;
+ val_ = NULL;
+#endif
+ return old;
+}
+
+
template <class T>
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) {
typedef internal::Internals I;
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698