From 0a5cb89744cbd737b73e2687fd546952caae0661 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 11 Sep 2012 16:06:50 +0200 Subject: explicitly yield() after broadcast() since it does not automatically yield (only when the broadcasting shred waits itself but this can be several messages later) fixes message loss for NanoEvents and RumbleEvents --- lib/NanoEvent.ck | 9 ++++++++- lib/RumbleEvent.ck | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/NanoEvent.ck b/lib/NanoEvent.ck index 2bf6378..9c501aa 100644 --- a/lib/NanoEvent.ck +++ b/lib/NanoEvent.ck @@ -64,8 +64,15 @@ public class NanoEvent extends GenEvent { msg.data3/127.0 => value; if (cmd == 0xB0 && - (wantScene == "" || scene == wantScene)) + (wantScene == "" || scene == wantScene)) { broadcast(); + /* + * ensure that shreds waiting on the event + * process it before it is overwritten + * by the next message in the queue + */ + me.yield(); + } } } /* not reached */ diff --git a/lib/RumbleEvent.ck b/lib/RumbleEvent.ck index 91aed80..d96635e 100644 --- a/lib/RumbleEvent.ck +++ b/lib/RumbleEvent.ck @@ -42,6 +42,12 @@ public class RumbleEvent extends GenEvent { <= IO.newline(); } else { broadcast(); + /* + * ensure that shreds waiting on the event + * process it before it is overwritten + * by the next message in the queue + */ + me.yield(); } } } -- cgit v1.2.3