[MLton-user] simple, portable, asynchronous programming in SML
Stephen Weeks
sweeks@sweeks.com
Tue, 1 Aug 2006 10:56:23 -0700
> I liked the EVENT signature, but confess to not having read the
> implementation.
Please send your feedback on the implementation when you get the
chance.
> Am I missing something?
> I don't see any conflict here at all.
I don't see a conflict either. However, given that my only prior
experience with this kind of stuff was from reading the CML book, I
was surprised in implementing EVENT and using it for a GUI that
threads were not as necessary as I had previously thought. Still
limited experience though.
> What I see is that there is some underlying event loop (in pretty
> much any non-command-line program), which fires off events. Stephan's
> system is just a way of standardizing what those events are.
Yes.
> If one wanted too, it would be easy (in MLton) to create a THREAD
> interface +structure which implemented a 'yieldUntil' function that
> waited for an event to be true. Then you get your non-preemptive
> threads and the callback system working together with a unified
> event type system.
Yep. In CML, yieldUntil is called sync and has the spec
val sync: 'a t -> 'a
It is easy to implement (in MLton or SML/NJ) although a bit of work
needs to be done to make the threads play nicely with runHandlers.
> Taking this further, one could imagine doing something like the
> rewrite/port of state-threads.sourceforge.net to SML I did, but in a
> cleaner way.
I had that in the back of my mind when I was working on this, and was
hoping you might comment on that, or even better try coding it :-).