From 2f07a40116597738dee409e81fa0a7f461985bdf Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sun, 11 May 2025 23:50:39 -0400 Subject: [PATCH] add a comment about async code and TK --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index f4b2fff..855b2e5 100644 --- a/main.go +++ b/main.go @@ -194,6 +194,16 @@ func moveSelectInFileList(target int) { } } +// TODO: by default, the event callback loop in TK is fully synchronous; +// each event only arrives after the previous event has finished processing. +// I'd like to make it so that multiple arrow presses cancel the in-flight +// image update, but because the TK renderer is running with [LockOSThread], +// just injecting goroutines willy-nilly results in horrible crashes. +// Supporting async handling would require plumbing channels throughout +// the render handler and making sure the main goroutine is the one that +// exclusively touches the TK API. +// +// [LockOSThread]: https://go.dev/wiki/LockOSThread func keyPress(e *tk.Event) { curr := directoryState.i switch e.Keysym {