From f19350aea316753caeb791f3a34a7691aad28492 Mon Sep 17 00:00:00 2001 From: jzhou Date: Tue, 8 May 2012 00:46:32 +0000 Subject: [PATCH] Changes for reading input files in MGC version --- Robust/src/ClassLibrary/MGC/Scanner.java | 14 +++ .../ClassLibrary/MGC/gnu/ConditionObject.java | 108 ++++++++++++++++++ Robust/src/Runtime/bamboo/multicoreruntime.c | 14 +++ 3 files changed, 136 insertions(+) create mode 100644 Robust/src/ClassLibrary/MGC/Scanner.java create mode 100644 Robust/src/ClassLibrary/MGC/gnu/ConditionObject.java diff --git a/Robust/src/ClassLibrary/MGC/Scanner.java b/Robust/src/ClassLibrary/MGC/Scanner.java new file mode 100644 index 00000000..9b595ae1 --- /dev/null +++ b/Robust/src/ClassLibrary/MGC/Scanner.java @@ -0,0 +1,14 @@ +public class Scanner implements Iterator { + private String sourcename; + + public Scanner (final String source) { + this.sourcename = source; + } + + public void close () { + } + + public native double nextDouble (); + + public native int nextInt (); +} \ 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 index 00000000..3df10067 --- /dev/null +++ b/Robust/src/ClassLibrary/MGC/gnu/ConditionObject.java @@ -0,0 +1,108 @@ +public class ConditionObject implements Condition { + /** + * Creates a new ConditionObject 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. + *
    + *
  1. Save lock state returned by {@link #getState} + *
  2. Invoke {@link #release} with + * saved state as argument, throwing + * IllegalMonitorStateException if it fails. + *
  3. Block until signalled + *
  4. Reacquire by invoking specialized version of + * {@link #acquire} with saved state as argument. + *
+ */ + public final void awaitUninterruptibly() { + this.wait(); + } + + /** + * Implements interruptible condition wait. + *
    + *
  1. If current thread is interrupted, throw InterruptedException + *
  2. Save lock state returned by {@link #getState} + *
  3. Invoke {@link #release} with + * saved state as argument, throwing + * IllegalMonitorStateException if it fails. + *
  4. Block until signalled or interrupted + *
  5. Reacquire by invoking specialized version of + * {@link #acquire} with saved state as argument. + *
  6. If interrupted while blocked in step 4, throw exception + *
+ */ + public final void await() throws InterruptedException { + this.wait(); + } + + /** + * Implements timed condition wait. + *
    + *
  1. If current thread is interrupted, throw InterruptedException + *
  2. Save lock state returned by {@link #getState} + *
  3. Invoke {@link #release} with + * saved state as argument, throwing + * IllegalMonitorStateException if it fails. + *
  4. Block until signalled, interrupted, or timed out + *
  5. Reacquire by invoking specialized version of + * {@link #acquire} with saved state as argument. + *
  6. If interrupted while blocked in step 4, throw InterruptedException + *
+ */ + public final long awaitNanos(long nanosTimeout) throws InterruptedException { + long lastTime = System.nanoTime(); + this.wait(); + return nanosTimeout - (System.nanoTime() - lastTime); + } + + /** + * Implements absolute timed condition wait. + *
    + *
  1. If current thread is interrupted, throw InterruptedException + *
  2. Save lock state returned by {@link #getState} + *
  3. Invoke {@link #release} with + * saved state as argument, throwing + * IllegalMonitorStateException if it fails. + *
  4. Block until signalled, interrupted, or timed out + *
  5. Reacquire by invoking specialized version of + * {@link #acquire} with saved state as argument. + *
  6. If interrupted while blocked in step 4, throw InterruptedException + *
  7. If timed out while blocked in step 4, return false, else true + *
+ */ + 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 diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 71f50c7a..306392cd 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -429,6 +429,20 @@ void CALL01(___System______printString____L___String___, struct ___String___ * _ } #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) -- 2.34.1