Files
sml-projects/shell/update-thread.sml

36 lines
995 B
Standard ML
Raw Normal View History

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
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
fun sendMsgs (msgList, drawMailbox, searchMailbox) =
2024-10-06 09:32:56 +01:00
case msgList of
hd :: tl =>
let val _ = sendMsg (hd, drawMailbox, searchMailbox)
in sendMsgs (tl, drawMailbox, searchMailbox)
2024-10-06 09:32:56 +01:00
end
| [] => ()
fun loop (app: AppType.app_type, inputMailbox, drawMailbox, searchMailbox) =
2024-10-06 09:32:56 +01:00
let
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
val () = ExceptionLogger.addCommand inputMsg
val app = AppUpdate.update (app, inputMsg, time)
2025-08-06 00:16:50 +01:00
handle e => ExceptionLogger.log e
val () = sendMsgs (#msgs app, drawMailbox, searchMailbox)
2024-10-06 09:32:56 +01:00
in
loop (app, inputMailbox, drawMailbox, searchMailbox)
2024-10-06 09:32:56 +01:00
end
end