scaffolding for concurrent ml

This commit is contained in:
2024-10-06 09:32:56 +01:00
parent 6766fd1485
commit b95fc48252
9 changed files with 73 additions and 40 deletions

25
shell/update-thread.sml Normal file
View File

@@ -0,0 +1,25 @@
structure UpdateThread =
struct
open CML
open MailboxType
fun sendMsg (msg, drawMailbox) =
case msg of DRAW msg => Mailbox.send (drawMailbox, msg)
fun sendMsgs (msgList, drawMailbox) =
case msgList of
hd :: tl =>
let val _ = sendMsg (hd, drawMailbox)
in sendMsgs (tl, drawMailbox)
end
| [] => ()
fun loop (app: AppType.app_type, inputMailbox, drawMailbox) =
let
val inputMsg = Mailbox.recv inputMailbox
val (app, msgList) = AppUpdate.update (app, inputMsg)
val _ = sendMsgs (msgList, drawMailbox)
in
loop (app, inputMailbox, drawMailbox)
end
end