2024-10-06 09:32:56 +01:00
|
|
|
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
|
2024-12-17 10:40:06 +00:00
|
|
|
val app = AppUpdate.update (app, inputMsg)
|
|
|
|
|
val () = sendMsgs (#msgs app, drawMailbox)
|
2024-10-06 09:32:56 +01:00
|
|
|
in
|
|
|
|
|
loop (app, inputMailbox, drawMailbox)
|
|
|
|
|
end
|
|
|
|
|
end
|