[e-lang] Techniques for batching messages

Kevin Reid kpreid at attglobal.net
Fri Nov 17 15:51:03 CST 2006


# This will send at most one message per cycle of the vat.

def buffer := <something mutable>

def flush() {
   recipient <- (buffer.snapshot())
   buffer.removeAll()
}

def input(data) {
   if (buffer.empty()) {
     flush <- ()
   }
   buffer.append(data)
}


# This version will send a message only after one cycle with no input
# being added.

def buffer := <something mutable>
var currentTag := null

def flush(tag) {
   if (tag == currentTag) {
     recipient <- (buffer.snapshot())
     buffer.removeAll()
   }
}

def input(data) {
   if (buffer.empty()) {
     flush <- (currentTag := def aTag {})
   }
   buffer.append(data)
}



-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list