Changes for reading input files in MGC version
authorjzhou <jzhou>
Tue, 8 May 2012 00:46:32 +0000 (00:46 +0000)
committerjzhou <jzhou>
Tue, 8 May 2012 00:46:32 +0000 (00:46 +0000)
Robust/src/ClassLibrary/MGC/Scanner.java [new file with mode: 0644]
Robust/src/ClassLibrary/MGC/gnu/ConditionObject.java [new file with mode: 0644]
Robust/src/Runtime/bamboo/multicoreruntime.c

diff --git a/Robust/src/ClassLibrary/MGC/Scanner.java b/Robust/src/ClassLibrary/MGC/Scanner.java
new file mode 100644 (file)
index 0000000..9b595ae
--- /dev/null
@@ -0,0 +1,14 @@
+public class Scanner implements Iterator {\r
+  private String sourcename;\r
+\r
+  public Scanner (final String source) {\r
+    this.sourcename = source;\r
+  }\r
+\r
+  public void close () {\r
+  }\r
+\r
+  public native double nextDouble ();\r
+\r
+  public native int nextInt ();\r
+}
\ No newline at end of file
diff --git a/Robust/src/ClassLibrary/MGC/gnu/ConditionObject.java b/Robust/src/ClassLibrary/MGC/gnu/ConditionObject.java
new file mode 100644 (file)
index 0000000..3df1006
--- /dev/null
@@ -0,0 +1,108 @@
+public class ConditionObject implements Condition {
+    /**
+     * Creates a new <tt>ConditionObject</tt> instance.
+     */
+    public ConditionObject() { }
+
+    // public methods
+
+    /**
+     * Moves the longest-waiting thread, if one exists, from the
+     * wait queue for this condition to the wait queue for the
+     * owning lock.
+     *
+     * @throws IllegalMonitorStateException if {@link #isHeldExclusively}
+     *         returns {@code false}
+     */
+    public final void signal() {
+       this.notifyAll();
+    }
+
+    /**
+     * Moves all threads from the wait queue for this condition to
+     * the wait queue for the owning lock.
+     *
+     * @throws IllegalMonitorStateException if {@link #isHeldExclusively}
+     *         returns {@code false}
+     */
+    public final void signalAll() {
+       this.notifyAll();
+    }
+
+    /**
+     * Implements uninterruptible condition wait.
+     * <ol>
+     * <li> Save lock state returned by {@link #getState}
+     * <li> Invoke {@link #release} with
+     *      saved state as argument, throwing
+     *      IllegalMonitorStateException if it fails.
+     * <li> Block until signalled
+     * <li> Reacquire by invoking specialized version of
+     *      {@link #acquire} with saved state as argument.
+     * </ol>
+     */
+    public final void awaitUninterruptibly() {
+       this.wait();
+    }
+
+    /**
+     * Implements interruptible condition wait.
+     * <ol>
+     * <li> If current thread is interrupted, throw InterruptedException
+     * <li> Save lock state returned by {@link #getState}
+     * <li> Invoke {@link #release} with
+     *      saved state as argument, throwing
+     *      IllegalMonitorStateException  if it fails.
+     * <li> Block until signalled or interrupted
+     * <li> Reacquire by invoking specialized version of
+     *      {@link #acquire} with saved state as argument.
+     * <li> If interrupted while blocked in step 4, throw exception
+     * </ol>
+     */
+    public final void await() throws InterruptedException {
+       this.wait();
+    }
+
+    /**
+     * Implements timed condition wait.
+     * <ol>
+     * <li> If current thread is interrupted, throw InterruptedException
+     * <li> Save lock state returned by {@link #getState}
+     * <li> Invoke {@link #release} with
+     *      saved state as argument, throwing
+     *      IllegalMonitorStateException  if it fails.
+     * <li> Block until signalled, interrupted, or timed out
+     * <li> Reacquire by invoking specialized version of
+     *      {@link #acquire} with saved state as argument.
+     * <li> If interrupted while blocked in step 4, throw InterruptedException
+     * </ol>
+     */
+    public final long awaitNanos(long nanosTimeout) throws InterruptedException {
+       long lastTime = System.nanoTime();
+       this.wait();
+       return nanosTimeout - (System.nanoTime() - lastTime);
+    }
+
+    /**
+     * Implements absolute timed condition wait.
+     * <ol>
+     * <li> If current thread is interrupted, throw InterruptedException
+     * <li> Save lock state returned by {@link #getState}
+     * <li> Invoke {@link #release} with
+     *      saved state as argument, throwing
+     *      IllegalMonitorStateException  if it fails.
+     * <li> Block until signalled, interrupted, or timed out
+     * <li> Reacquire by invoking specialized version of
+     *      {@link #acquire} with saved state as argument.
+     * <li> If interrupted while blocked in step 4, throw InterruptedException
+     * <li> If timed out while blocked in step 4, return false, else true
+     * </ol>
+     */
+    public final boolean awaitUntil(Date deadline) throws InterruptedException {
+       long abstime = deadline.getTime();
+       boolean timedout = false;
+       int interruptMode = 0;
+       this.wait();
+       return !timedout;
+    }
+}
\ No newline at end of file
index 71f50c7a2292f5506830bb5bca9ecb998c056fab..306392cd57bab4d19cc40313953db78e3062e651 100644 (file)
@@ -429,6 +429,20 @@ void CALL01(___System______printString____L___String___, struct ___String___ * _
 }
 #endif
 
 }
 #endif
 
+#ifdef D___Scanner______nextDouble____ 
+double ___Scanner______nextDouble____(struct ___Scanner______nextDouble_____params * ___params___) {
+  // TODO
+  return 0;
+}
+#endif
+
+#ifdef D___Scanner______nextInt____ 
+int ___Scanner______nextInt____(struct ___Scanner______nextInt_____params * ___params___) {
+  // TODO
+  return 0;
+}
+#endif
+
 /* Object allocation function */
 
 #if defined(MULTICORE_GC)||defined(PMC_GC)
 /* Object allocation function */
 
 #if defined(MULTICORE_GC)||defined(PMC_GC)