On Thu, Nov 17, 2011 at 3:47 PM, Joshua Bell <jsb...@chromium.org> wrote:
> ^^^ Nit: That would revert back to being postMessage(), no new API on the > Worker side. > Right, I just copied your example. (You mean "no new API for sending messages"--the "get the next event" method would be new API for workers.) One concern with this overall approach is that any pending message would be > grabbed, not just one intended as a response. > You just create separate MessagePorts to segregate different types of messages. messagePort.getMessageIfExists would only retrieve messages on messagePort. "Retrieve the first message from a list of message ports", akin to poll/select, may also be useful, eg. getFirstMessage([port1, port2], timeout). I'm not sure if there are use cases for this, but it's worth mentioning. I agree that "return" makes more sense than "dispatch", since we're > introducing this to support a linear programming style. On the other hand, > you could emulate "return" with "dispatch" via helper functions that swap > in a temporary onmessage handler (a variant on your > getPendingMessageWithoutDelivery example in the older thread) > Right, you can emulate either using the other. Alternatively, do both: fire the event synchronously, then return it. -- Glenn Maynard