module Producer(CON) {
export {
function isEmpty();
function produce();
};
function get() {
};
function produce() {
while (not CON:isFull()) {
item = newItem();
}
};
};
module Consumer(PROD) {
export {
function isEmpty();
function consume();
};
function consume() {
while (not PROD:isFull()) {
item = PROD:getItem();
use(item);
}
};
};
module Connector() {
prod = import Producer;
con = import Consumer;
};
// ports are untyped -- just like properties or function parameters
// also, a port can be either a property, event, or a function
module CameraModule(VOUT) {
export {
property pBatteryLife;
stream sImageStream;
event eCameraTurnedOn;
event eCameraTurnedOff;
event eBatteryLow;
function fTurnOnCamera;
};
// definitions of eexported functions
// local properties, events, functions, reactors
};
module DisplayModule(VIN) {
exported {
};
};
module CameraAndDisplayCoordinator() {
mod disp = import(DisplayModule());
mod cam = import(CameraModule());
// :CONNECT is a special system function which connects two ports
// :DISCONNECT is another system function
// Q: Do we really need :CONNECT? Can we just add function setVideoIn(VIN) to
// DisplayModule?
:CONNECT(disp.VIN, disp.VOUT);
reactor R1(disp.eBatteryLife) {
// ...
};
};
// dev0
function foo() {
dev1:bar!();
fork {
@(ev0) {
}
@(ev1) {
}
} join(ANY);
}
// dev1
function bar() {
->
}