From 3b2a6e76eecf6c64156e047053492778421ba437 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 2 May 2012 21:24:33 +0200 Subject: [PATCH] Do not embeed our version of semaphores Java 1.5 can be considered as sufficiently prevalent for us to not dupplicate its features. Closes #14217. --- CMakeLists.txt | 1 - ChangeLog | 3 ++ org/simgrid/msg/Process.java | 7 +++-- org/simgrid/msg/Sem.java | 56 ------------------------------------ 4 files changed, 7 insertions(+), 60 deletions(-) delete mode 100644 org/simgrid/msg/Sem.java diff --git a/CMakeLists.txt b/CMakeLists.txt index 88dccf44aa..44081245bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,6 @@ set(JMSG_JAVA_SRC org/simgrid/msg/Process.java org/simgrid/msg/ProcessKilled.java org/simgrid/msg/ProcessNotFoundException.java - org/simgrid/msg/Sem.java org/simgrid/msg/Task.java org/simgrid/msg/TaskCancelledException.java org/simgrid/msg/TimeoutException.java diff --git a/ChangeLog b/ChangeLog index ef7fd9f919..823c6fe52c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ SimGrid-java (3.6.1) unstable; urgency=low + + * Do not embeed our version of semaphores, java 1.5 can be considered + as sufficiently prevalent for us to not dupplicate its features. * Make Process.kill(process) an instance method, not a static one * Fix a bug around Process.kill() * Add dsend and simulatedSleep to the bindings. diff --git a/org/simgrid/msg/Process.java b/org/simgrid/msg/Process.java index 10591d3595..d5e10d690b 100644 --- a/org/simgrid/msg/Process.java +++ b/org/simgrid/msg/Process.java @@ -14,6 +14,7 @@ package org.simgrid.msg; import java.util.Arrays; import java.util.Hashtable; import java.util.Vector; +import java.util.concurrent.Semaphore; /** * A process may be defined as a code, with some private data, executing @@ -105,7 +106,7 @@ public abstract class Process extends Thread { /** * */ - protected Sem schedBegin, schedEnd; + protected Semaphore schedBegin, schedEnd; private boolean nativeStop = false; /** @@ -118,8 +119,8 @@ public abstract class Process extends Thread { this.bind = 0; this.args = new Vector(); this.properties = null; - schedBegin = new Sem(0); - schedEnd = new Sem(0); + schedBegin = new Semaphore(0); + schedEnd = new Semaphore(0); } diff --git a/org/simgrid/msg/Sem.java b/org/simgrid/msg/Sem.java deleted file mode 100644 index e034d1a67b..0000000000 --- a/org/simgrid/msg/Sem.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Simple semaphore implementation, from Doug Lea (public domain) - * - * Copyright 2006,2007,2010,2011 The SimGrid Team - * All right reserved. - * - * This program is free software; you can redistribute - * it and/or modify it under the terms of the license - *(GNU LGPL) which comes with this package. - */ - -package org.simgrid.msg; - -public class Sem { - /******************************************************************/ - /* Simple semaphore implementation, from Doug Lea (public domain) */ - /******************************************************************/ - private int permits_; - - /** - * - * @param i - */ - public Sem(int i) { - permits_ = i; - } - - /** - * - * @throws java.lang.InterruptedException - */ - public void acquire() throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - - synchronized(this) { - try { - while (permits_ <= 0) - wait(); - --permits_; - } - catch(InterruptedException ex) { - notify(); - throw ex; - } - } - } - - /** - * - */ - public synchronized void release() { - ++(this.permits_); - notify(); - } -} -- 2.20.1