[m-rev.] diff: make some java classes serializable

Peter Ross pro at missioncriticalit.com
Fri Oct 8 15:52:32 AEDT 2010


On Thu, Oct 07, 2010 at 05:44:21PM +1100, Peter Wang wrote:
> Branches: main
> 
> library/bitmap.m:
> library/builtin.m:
> library/mutvar.m:
> library/version_array.m:
>         Make hand-written Java classes in these modules implement
>         `java.io.Serializable'.
> 

Make the version_array serialize on the java backend.

===================================================================


Estimated hours taken: 0.25
Branches: main, 10.04

library/version_array.m:
	Make the locks inside the java version arrays serializable as well.


Index: library/version_array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/version_array.m,v
retrieving revision 1.27
diff -u -r1.27 version_array.m
--- library/version_array.m	7 Oct 2010 06:43:28 -0000	1.27
+++ library/version_array.m	8 Oct 2010 04:49:45 -0000
@@ -1321,6 +1321,10 @@
     public int size();
 }
 
+public static class Lock implements java.io.Serializable {
+    public Lock() { return; }
+}
+
 // An implementation of version arrays that is safe when used in multiple
 // threads.
 //
@@ -1328,11 +1332,11 @@
 // that only one thread can be accessing the array at one instant.
 public static class ML_sva implements ML_va, java.io.Serializable {
     private ML_uva version_array;
-    private Object lock;
+    private Lock lock;
 
     public ML_sva(ML_uva va) {
         version_array = va;
-        lock = new Object();
+        lock = new Lock();
     }
 
     private ML_sva() {};
@@ -1351,7 +1355,7 @@
 
             if (result.version_array.isClone()) {
                 result.version_array.resetIsClone();
-                result.lock = new Object();
+                result.lock = new Lock();
             } else {
                 result.lock = this.lock;
             }
@@ -1364,7 +1368,7 @@
         synchronized (lock) {
             ML_sva result = new ML_sva();
             result.version_array = version_array.resize(N, X);
-            result.lock = new Object();
+            result.lock = new Lock();
             return result;
         }
     }

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list