1 #import edu.berkeley.fleet.ships
3 #ship helper : FifoShip
4 #ship source : FifoShip
7 #ship fetch : FetchShip
8 #ship tokensource : TokenSourceShip
10 // NOTE: "accept" is a synonym for "move" it is less confusing in the case
11 // of inboxes, but is otherwise identical
14 //////////////////////////////////////////////////////////////////////////////
15 // The following three instructions simply produce one hundred "3"s
16 // and put them into fifo "a". Ignore the switch-fabric clogging
17 // issue here; this is just setup for the rest of the code.
20 copy helper.out -[10]-> source.in
21 discard helper.out -> ()
24 //////////////////////////////////////////////////////////////////////////////
25 // set up a counting move of 10 items from source.out to dest.in, but require
26 // flow control tokens (10 items is too many to send at once)
28 triggered move source.out -[10]-> dest.in
31 //////////////////////////////////////////////////////////////////////////////
32 // The next instruction tears down the "default" standing move on dest.in
33 // and uses the resulting tokens to prime source.out's pump. Once that
34 // has been kicked off, any subsequent incoming items will generate tokens
35 // which are sent back to the source outbox
37 nop+ack dest.in -[3]-> source.out
38 accept+ack dest.in -[10]-> source.out
39 nop+ack dest.in -> fetch.release // then release the fetch
40 accept dest.in -[*]-> () // and return the fabric to normal
42 { tokensource.out -> halt.in } -> fetch.codebag // termination codebag