update docs
[fleet.git] / ships / Fifo.ship
1 ship: Fifo
2
3 == Ports ===========================================================
4 data  in:   in
5
6 data  out:  out
7
8 == Constants ========================================================
9
10 == TeX ==============================================================
11
12 The {\tt Fifo} ship is a simple fifo.  Word-sized delivered to the {\tt
13 in} port are enqueued into the fifo, and values which arrive at the
14 end of the fifo are provided to the {\tt out} port.
15
16 The internal capacity of the fifo is unspecified, but guaranteed to be
17 at least 16 words.
18
19 == Fleeterpreter ====================================================
20     private Queue<Long> fifo = new LinkedList<Long>();
21     public void service() {
22         if (box_in.dataReadyForShip()) {
23             fifo.add(box_in.removeDataForShip());
24         }
25         if (box_out.readyForDataFromShip() && fifo.size() > 0) {
26             box_out.addDataFromShip(fifo.remove());
27         }
28     }
29
30 == FleetSim ==============================================================
31
32 == Test =================================================================
33 // expected output
34 #expect 9
35
36 // ships required in order to run this code
37 #ship debug        : Debug
38 #ship fifo         : Fifo
39
40 debug.in:   [*] take, deliver;
41 fifo.in:
42   literal 9;
43   deliver;
44   [100] take, deliver;
45 fifo.out:
46   [99] take, sendto fifo.in;
47   [1]  take, sendto debug.in;
48
49
50
51 == Contributors =========================================================
52 Adam Megacz <megacz@cs.berkeley.edu>