2024-10-06 09:32:56 +01:00
|
|
|
structure UpdateThread =
|
|
|
|
|
struct
|
|
|
|
|
open CML
|
|
|
|
|
open MailboxType
|
2025-08-04 09:29:37 +01:00
|
|
|
open InputMsg
|
2024-10-06 09:32:56 +01:00
|
|
|
|
2025-08-07 12:20:57 +01:00
|
|
|
fun sendMsg (msg, drawMailbox, searchMailbox) =
|
|
|
|
|
case msg of
|
|
|
|
|
DRAW msg => Mailbox.send (drawMailbox, msg)
|
|
|
|
|
| SEARCH (buffer, searchString) =>
|
|
|
|
|
Mailbox.send (searchMailbox, (buffer, searchString))
|
2024-10-06 09:32:56 +01:00
|
|
|
|
2025-08-07 12:20:57 +01:00
|
|
|
fun sendMsgs (msgList, drawMailbox, searchMailbox) =
|
2024-10-06 09:32:56 +01:00
|
|
|
case msgList of
|
|
|
|
|
hd :: tl =>
|
2025-08-07 12:20:57 +01:00
|
|
|
let val _ = sendMsg (hd, drawMailbox, searchMailbox)
|
|
|
|
|
in sendMsgs (tl, drawMailbox, searchMailbox)
|
2024-10-06 09:32:56 +01:00
|
|
|
end
|
|
|
|
|
| [] => ()
|
|
|
|
|
|
2025-08-07 12:20:57 +01:00
|
|
|
fun loop (app: AppType.app_type, inputMailbox, drawMailbox, searchMailbox) =
|
2024-10-06 09:32:56 +01:00
|
|
|
let
|
2025-08-20 12:50:39 +01:00
|
|
|
val time = Time.now ()
|
2024-10-06 09:32:56 +01:00
|
|
|
val inputMsg = Mailbox.recv inputMailbox
|
2025-08-04 09:29:37 +01:00
|
|
|
|
2025-08-04 09:03:47 +01:00
|
|
|
val () = ExceptionLogger.addCommand inputMsg
|
2025-08-04 06:23:52 +01:00
|
|
|
|
2025-08-20 12:50:39 +01:00
|
|
|
val app = AppUpdate.update (app, inputMsg, time)
|
2025-08-06 00:16:50 +01:00
|
|
|
handle e => ExceptionLogger.log e
|
2025-08-03 13:14:28 +01:00
|
|
|
|
2025-08-07 12:20:57 +01:00
|
|
|
val () = sendMsgs (#msgs app, drawMailbox, searchMailbox)
|
2024-10-06 09:32:56 +01:00
|
|
|
in
|
2025-08-07 12:20:57 +01:00
|
|
|
loop (app, inputMailbox, drawMailbox, searchMailbox)
|
2024-10-06 09:32:56 +01:00
|
|
|
end
|
|
|
|
|
end
|