Browse Source

upm: new upm.i JS interface file with code to call v8 garbage collector

Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Zion Orent 10 years ago
parent
commit
73be07df74
1 changed files with 19 additions and 0 deletions
  1. 19
    0
      src/upm.i

+ 19
- 0
src/upm.i View File

@@ -2,3 +2,22 @@
2 2
 %include "stdint.i"
3 3
 
4 4
 %typemap(out) mraa_result_t = int;
5
+
6
+#if (SWIG_JAVASCRIPT_V8)
7
+%{
8
+	// Because there's no guarantee that v8 will ever call garbage collection,
9
+	// we're adding a function that will allow a user to call it manually
10
+	void cleanUp()
11
+	{
12
+		// Call the v8 garbage collector as long as there is memory to clean up
13
+		// See https://codereview.chromium.org/412163003 for this API change
14
+#if (SWIG_V8_VERSION < 0x032838)
15
+		while (!v8::V8::IdleNotification())
16
+#else
17
+		while (!v8::Isolate::GetCurrent()->IdleNotification(1000))
18
+#endif
19
+		{;}
20
+	}
21
+%}
22
+void cleanUp();
23
+#endif