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

Unified Diff: utils/archive/utils.dart

Issue 10825139: Free the C memory for ArchiveInputStream when the stream is garbage collected. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a renamed function Created 8 years, 5 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
Index: utils/archive/utils.dart
diff --git a/utils/archive/utils.dart b/utils/archive/utils.dart
index f85101b8860649a2ec6615dee09eae56fa0f2ffc..433cd9abba0547249def3437fd1336fdadcda4f2 100644
--- a/utils/archive/utils.dart
+++ b/utils/archive/utils.dart
@@ -58,6 +58,32 @@ Uint8List bytesForC(List<int> input) {
}
/**
+ * Attaches [callback] as a finalizer for [object]. After [object] has been
+ * garbage collected, [callback] will be called and passed [peer] as an
+ * argument.
+ *
+ * Neither [callback] nor [peer] should contain any references to [object];
+ * otherwise, [object] will never be collected and [callback] will never be
+ * called.
+ */
+void attachFinalizer(object, void callback(peer), [peer])
+ native "Archive_AttachFinalizer";
+
+/**
+ * A reference to a single value.
+ *
+ * This is primarily meant to be used when a finalizer needs to refer to a field
+ * on the object being finalized that may be set to null during the lifetime of
+ * the object. Since the object itself has been garbage collected once the
+ * finalizer runs, it needs a second-order reference to check if the field is
+ * null.
+ */
+class Reference<E> {
+ E value;
+ Reference(this.value);
+}
+
+/**
* Returns a [Future] that completes immediately upon hitting the event loop.
*/
Future async() {

Powered by Google App Engine
This is Rietveld 408576698