Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix in Mutex comments
[simgrid.git] / org / simgrid / msg / Mutex.java
index bf0bac7d028559d1082b96192224292406e26e58..093055267d92ece117f2d120b848056024b7d85d 100644 (file)
@@ -1,8 +1,4 @@
-package org.simgrid.msg;
-/** A mutex  implemented on top of SimGrid synchronization mechanisms. 
- * You can use it exactly the same way that you use the mutexes, 
- * but to handle the interactions between the threads within the simulation.   
- * 
+/* 
  * Copyright 2012 The SimGrid team. All right reserved. 
  *
  * This program is free software; you can redistribute 
@@ -10,13 +6,33 @@ package org.simgrid.msg;
  * (GNU LGPL) which comes with this package.
  *
  */
+package org.simgrid.msg;
+/** A mutex  implemented on top of SimGrid synchronization mechanisms. 
+ * You can use it exactly the same way that you use the mutexes, 
+ * but to handle the interactions between the processes within the simulation.   
+ *
+ */
 public class Mutex {
        private long bind; // The C object -- don't touch it
        
        public Mutex(int capa) {
                init(capa);
        }
+       protected void finalize() {
+               exit();
+       }
+       private native void exit();
        private native void init(int capacity);
        public native void acquire();
        public native void release();
+       
+       /**
+        * Class initializer, to initialize various JNI stuff
+        */
+       public static native void nativeInit();
+       static {
+               nativeInit();
+       }       
 }
+
+