[e-lang] Techniques for batching messages
Dean Tribble
tribble at e-dean.com
Fri Nov 17 21:00:28 CST 2006
This is an important pattern because it allows an event loop to merge calls
(e.g., redisplay events), suppress duplicates, etc. Very nice.
On 11/17/06, Kevin Reid <kpreid at attglobal.net> wrote:
>
>
> # 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/>
>
>
> _______________________________________________
> e-lang mailing list
> e-lang at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eros-os.org/pipermail/e-lang/attachments/20061117/83b92a5c/attachment.html
More information about the e-lang
mailing list