summaryrefslogtreecommitdiff
path: root/RTJava
diff options
context:
space:
mode:
authorAngelo Corsaro <angelo@icorsaro.net>2001-02-03 01:49:55 +0000
committerAngelo Corsaro <angelo@icorsaro.net>2001-02-03 01:49:55 +0000
commita42e0462455b2aa96d0b415c96828702e0efee7b (patch)
treea81f36fb1155daf38d746016e78545b33f06834e /RTJava
parentfd6285fe574cbe269b767b18d088c21617485786 (diff)
downloadATCD-a42e0462455b2aa96d0b415c96828702e0efee7b.tar.gz
Fri Feb 02 19:49:28 2001 Angelo Corsaro <corsaro@cs.wustl.edu>
Diffstat (limited to 'RTJava')
-rw-r--r--RTJava/ChangeLog14
-rw-r--r--RTJava/README5
-rw-r--r--RTJava/docs/CodingStyle.txt8
-rw-r--r--RTJava/examples/tank/Refiller.java26
-rw-r--r--RTJava/examples/tank/Tank.java72
5 files changed, 125 insertions, 0 deletions
diff --git a/RTJava/ChangeLog b/RTJava/ChangeLog
index b3139252db0..8fd28d94be1 100644
--- a/RTJava/ChangeLog
+++ b/RTJava/ChangeLog
@@ -1,3 +1,17 @@
+Fri Feb 02 19:49:28 2001 Angelo Corsaro <corsaro@cs.wustl.edu>
+
+ * README:
+ Added some more notes... But not completed yet.
+
+ * docs/CodingStyle.txt:
+ Added file cotaining the coding style that should be used.
+
+ * examples/tank/Refiller.java:
+ * examples/tank/Bucket.java:
+ Created new example that will show how to use perioric
+ task as well as Asynchronous event handlers and other
+ RT Java features.
+
Fri Feb 02 00:59:59 2001 Angelo Corsaro <corsaro@cs.wustl.edu>
* benchmarks/RawSpeed:
diff --git a/RTJava/README b/RTJava/README
index a6f91b22b09..4b32c22c60d 100644
--- a/RTJava/README
+++ b/RTJava/README
@@ -1,3 +1,8 @@
This directory contains a series of benchmarks for evaluating the
RealTime JVM performance, and a series of example that are intented
to show how certain feature of the RT Java should be used.
+
+Make sure you read the file docs/CodingStyle.txt before you start
+adding code to the repository, so that all our code can look uniform
+and it will be easier for all of us to understand and read each
+other code. \ No newline at end of file
diff --git a/RTJava/docs/CodingStyle.txt b/RTJava/docs/CodingStyle.txt
new file mode 100644
index 00000000000..e0e70b73e78
--- /dev/null
+++ b/RTJava/docs/CodingStyle.txt
@@ -0,0 +1,8 @@
+The coding guideline to be used are those specified by the
+document "Java[tm] Coding Style Guide" that can be found at:
+
+ http://www.sun.com/forte/whitepapers/
+
+
+
+
diff --git a/RTJava/examples/tank/Refiller.java b/RTJava/examples/tank/Refiller.java
new file mode 100644
index 00000000000..1ceea495854
--- /dev/null
+++ b/RTJava/examples/tank/Refiller.java
@@ -0,0 +1,26 @@
+package tank;
+
+/**
+ * This class represent an activity that refills periodically
+ * the bucket. In this application it is assumed that this activity
+ * should be carried periodically.
+ */
+public class Refiller implements java.lang.Runnable {
+
+ /**
+ * Constructs a refiller that refills the tank every
+ * given amount of time.
+ *
+ * @param period The period of time at which the refill should
+ * occur.
+ */
+ public Refiller(int period) {
+ this.period = period;
+ }
+
+ public Refiller(int period) {
+ this.period = period;
+ }
+
+ protected long period;
+}
diff --git a/RTJava/examples/tank/Tank.java b/RTJava/examples/tank/Tank.java
new file mode 100644
index 00000000000..41483d8f266
--- /dev/null
+++ b/RTJava/examples/tank/Tank.java
@@ -0,0 +1,72 @@
+package tank;
+
+/**
+ * This class represent a bucket from which some kind of
+ * liquid ca be refilled or spilled.
+ */
+public class Tank {
+
+ /**
+ * Creates a bucket that can contains at most a given
+ * amount of liquid and that has initially available a
+ * given quantity.
+ *
+ * @param capacity The capacity of the Tank in liters.
+ * @param available The quantity of liquid initially available in
+ * the bucket.
+ */
+ public Tank(long capacity, long available) {
+ this.capacity = capacity;
+ this.available = abailable;
+ }
+
+ /**
+ * Refills the bucket with a given amount of liquid.
+ *
+ * @param amount The amount of liquid added to the bucket.
+ */
+ public void refill(long amount) {
+ this.available = java.lang.Math.min(this.capacity, amount+this.available);
+
+ // Here we should check for an overflow.
+ if (this.available > capacity)
+ this.overflowEvent.fire();
+ }
+
+ /**
+ * Spills from the bucket a given amount of liquid.
+ *
+ * @param amount The amount of liquid added to the bucket.
+ */
+ public void spill(long amount) {
+ this.available = java.lang.Math.max(0, this.available-amount);
+ if (this.available < amount)
+ this.underflowEven.fire();
+ }
+
+ /**
+ * Adds an AsyncEventHandler that will be called by the scheduler
+ * each time an overflow occurs.
+ *
+ * @param handler Ther overflow handler.
+ */
+ public void addOverflowHandler(AsyncEventHandler handler) {
+ this.overflowEvent.addHandler(handler);
+ }
+
+ /**
+ * Adds an AsyncEventHandler that will be called by the scheduler
+ * each time an underflow occurs.
+ *
+ * @param handler Ther underflow handler.
+ */
+ public void addUnderflowHandler(AsyncEventHandler handler) {
+ this.underflowEvent.addHandler(handler);
+ }
+
+ protected long capacity;
+ protected long available;
+
+ protected AsynchEvent overflowEvent;
+ protected AsynchEven underflowEvent;
+}