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