Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ed7340be756ed152f771b1030a2ac612668784b8
[simgrid.git] / src / bindings / java / org / simgrid / msg / Mutex.java
1 /* Copyright (c) 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package org.simgrid.msg;
8 /** A mutex  implemented on top of SimGrid synchronization mechanisms. 
9  * You can use it exactly the same way that you use the mutexes, 
10  * but to handle the interactions between the processes within the simulation.   
11  *
12  */
13 public class Mutex {
14         private long bind; // The C object -- don't touch it
15
16         public Mutex() {
17                 init();
18         }
19         @Override
20         protected void finalize() {
21                 try {
22                         nativeFinalize();
23                 } catch (Throwable e) {
24                         e.printStackTrace();
25                 }
26         }
27         private native void nativeFinalize();
28         private native void init();
29         public native void acquire();
30         public native void release();
31
32         /**
33          * Class initializer, to initialize various JNI stuff
34          */
35         public static native void nativeInit();
36         static {
37                 org.simgrid.NativeLib.nativeInit();
38                 nativeInit();
39         }       
40 }
41
42