[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: merged in sleep patch

Kaffe CVS cvs-commits at kaffe.org
Wed Jan 5 16:08:58 PST 2005


PatchSet 5778 
Date: 2005/01/06 00:04:25
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: merged in sleep patch

Members: 
	ChangeLog:1.3322->1.3323 
	libraries/clib/native/Thread.c:1.22->1.23 
	libraries/javalib/java/lang/Thread.java:1.51->1.52 
	libraries/javalib/java/lang/VMThread.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3322 kaffe/ChangeLog:1.3323
--- kaffe/ChangeLog:1.3322	Wed Jan  5 23:43:09 2005
+++ kaffe/ChangeLog	Thu Jan  6 00:04:25 2005
@@ -1,3 +1,19 @@
+2005-01-06  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/clib/native/Thread.c (java_lang_VMThread_sleep): 
+	Removed Guilhem's hack since the sleep patch has been merged in
+	from GNU Classpath.
+
+2005-01-05  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+
+	2004-12-30  Mark Wielaard  <mark at klomp.org>
+
+	* java/lang/Thread.java (sleep): Update documentation. Make sure
+	VMThread.sleep() is never called with zero arguments.
+	* vm/reference/java/lang/VMThread.java (sleep): Update documentation.
+
 2005-01-05  Dalibor Topic  <robilad at kaffe.org>
 
 	Resynced with GNU Classpath.
Index: kaffe/libraries/clib/native/Thread.c
diff -u kaffe/libraries/clib/native/Thread.c:1.22 kaffe/libraries/clib/native/Thread.c:1.23
--- kaffe/libraries/clib/native/Thread.c:1.22	Sun Jan  2 19:03:34 2005
+++ kaffe/libraries/clib/native/Thread.c	Thu Jan  6 00:04:26 2005
@@ -82,10 +82,6 @@
 {
   jthread_t	cur = KTHREAD(current)();
 
-  /* Temporary hack waiting for the Classpath merge. */
-  if (timeout == 0)
-    return;
-
   if(KTHREAD(interrupted)(cur))
     {
       throwException(InterruptedException);
Index: kaffe/libraries/javalib/java/lang/Thread.java
diff -u kaffe/libraries/javalib/java/lang/Thread.java:1.51 kaffe/libraries/javalib/java/lang/Thread.java:1.52
--- kaffe/libraries/javalib/java/lang/Thread.java:1.51	Wed Dec  8 07:22:33 2004
+++ kaffe/libraries/javalib/java/lang/Thread.java	Thu Jan  6 00:04:27 2005
@@ -769,11 +769,11 @@
    * are no guarantees which thread will be next to run, but most VMs will
    * choose the highest priority thread that has been waiting longest.
    *
-   * @param ms the number of milliseconds to sleep, or 0 for forever
-   * @throws InterruptedException if the Thread is interrupted; it's
-   *         <i>interrupted status</i> will be cleared
-   * @see #notify()
-   * @see #wait(long)
+   * @param ms the number of milliseconds to sleep.
+   * @throws InterruptedException if the Thread is (or was) interrupted;
+   *         it's <i>interrupted status</i> will be cleared
+   * @throws IllegalArgumentException if ms is negative
+   * @see #interrupt()
    */
   public static void sleep(long ms) throws InterruptedException
   {
@@ -785,27 +785,37 @@
    * time. The Thread will not lose any locks it has during this time. There
    * are no guarantees which thread will be next to run, but most VMs will
    * choose the highest priority thread that has been waiting longest.
+   * <p>
+   * Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs
+   * do not offer that fine a grain of timing resolution. When ms is
+   * zero and ns is non-zero the Thread will sleep for at least one
+   * milli second. There is no guarantee that this thread can start up
+   * immediately when time expires, because some other thread may be
+   * active.  So don't expect real-time performance.
    *
-   * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-   * not offer that fine a grain of timing resolution. Besides, there is
-   * no guarantee that this thread can start up immediately when time expires,
-   * because some other thread may be active.  So don't expect real-time
-   * performance.
-   *
-   * @param ms the number of milliseconds to sleep, or 0 for forever
+   * @param ms the number of milliseconds to sleep
    * @param ns the number of extra nanoseconds to sleep (0-999999)
-   * @throws InterruptedException if the Thread is interrupted; it's
-   *         <i>interrupted status</i> will be cleared
-   * @throws IllegalArgumentException if ns is invalid
-   * @see #notify()
-   * @see #wait(long, int)
+   * @throws InterruptedException if the Thread is (or was) interrupted;
+   *         it's <i>interrupted status</i> will be cleared
+   * @throws IllegalArgumentException if ms or ns is negative
+   *         or ns is larger than 999999.
+   * @see #interrupt()
    */
   public static void sleep(long ms, int ns) throws InterruptedException
   {
-    if(ms < 0 || ns < 0 || ns > 999999)
-	throw new IllegalArgumentException();
+    if (ms < 0 || ns < 0 || ns > 999999)
+      throw new IllegalArgumentException();
+
+    if (ns > 0 && ms == 0)
+      {
+	ms = 1;
+	ns = 0;
+      }
 
-    VMThread.sleep(ms, ns);
+    if (ms > 0)
+      VMThread.sleep(ms, ns);
+    else if (interrupted())
+      throw new InterruptedException();
   }
 
   /**
Index: kaffe/libraries/javalib/java/lang/VMThread.java
diff -u kaffe/libraries/javalib/java/lang/VMThread.java:1.2 kaffe/libraries/javalib/java/lang/VMThread.java:1.3
--- kaffe/libraries/javalib/java/lang/VMThread.java:1.2	Sun Oct 31 14:35:37 2004
+++ kaffe/libraries/javalib/java/lang/VMThread.java	Thu Jan  6 00:04:27 2005
@@ -382,11 +382,10 @@
      * because some other thread may be active.  So don't expect real-time
      * performance.
      *
-     * @param ms the number of milliseconds to sleep, or 0 for forever
+     * @param ms the number of milliseconds to sleep. Will be at least 1.
      * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is interrupted; it's
-     *         <i>interrupted status</i> will be cleared
-     * @throws IllegalArgumentException if ns is invalid
+     * @throws InterruptedException if the Thread is (or was) interrupted;
+     *         it's <i>interrupted status</i> will be cleared
      */
     static native void sleep(long ms, int ns) throws InterruptedException;
 




More information about the kaffe mailing list