Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / org / simgrid / msg / Sem.java
index 84ab9f2..e034d1a 100644 (file)
@@ -1,35 +1,56 @@
 /*\r
  * Simple semaphore implementation, from Doug Lea (public domain)\r
  *\r
- * Copyright 2006,2007,2010 The SimGrid Team           \r
+ * Copyright 2006,2007,2010,2011 The SimGrid Team           \r
  * All right reserved. \r
  *\r
  * This program is free software; you can redistribute \r
  * it and/or modify it under the terms of the license \r
  *(GNU LGPL) which comes with this package. \r
  */  \r
-\rpackage org.simgrid.msg;
-\r\rpublic class Sem {\r
+\r
+package org.simgrid.msg;\r
+\r
+public class Sem {\r
        /******************************************************************/ \r
        /* Simple semaphore implementation, from Doug Lea (public domain) */ \r
        /******************************************************************/ \r
-       private int permits_;
-\r      public Sem(int i) {\r            permits_ = i;\r  } \r\r    public void acquire() throws InterruptedException {
-               if (Thread.interrupted())
-                       throw new InterruptedException();
-\r              synchronized(this) {
-                       try {
-                               while (permits_ <= 0)
-                                       wait();
-                               --permits_;
-                       }
-                       catch(InterruptedException ex) {
-                               notify();
-                               throw ex;
-                       }
-               }
-       }
-\r      public synchronized void release() {
-               ++(this.permits_);
-               notify();
-       } \r\r
+       private int permits_;\r
+\r
+    /**\r
+     *\r
+     * @param i\r
+     */\r
+    public Sem(int i) {\r
+               permits_ = i;\r
+       } \r
+\r
+    /**\r
+     *\r
+     * @throws java.lang.InterruptedException\r
+     */\r
+    public void acquire() throws InterruptedException {\r
+               if (Thread.interrupted())\r
+                       throw new InterruptedException();\r
+\r
+               synchronized(this) {\r
+                       try {\r
+                               while (permits_ <= 0)\r
+                                       wait();\r
+                               --permits_;\r
+                       }\r
+                       catch(InterruptedException ex) {\r
+                               notify();\r
+                               throw ex;\r
+                       }\r
+               }\r
+       }\r
+\r
+    /**\r
+     *\r
+     */\r
+    public synchronized void release() {\r
+               ++(this.permits_);\r
+               notify();\r
+       } \r
+} \r