aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui/ui.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ui/ui.go')
-rw-r--r--lib/ui/ui.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ui/ui.go b/lib/ui/ui.go
index 313f90d8..ea181d33 100644
--- a/lib/ui/ui.go
+++ b/lib/ui/ui.go
@@ -13,12 +13,22 @@ const (
var MsgChannel = make(chan AercMsg, 50)
+type AercFuncMsg struct {
+ Func func()
+}
+
// QueueRedraw sends a nil message into the MsgChannel. Nothing will handle this
// message, but a redraw will occur if the UI is marked as invalid
func QueueRedraw() {
MsgChannel <- nil
}
+// QueueFunc queues a function to be called in the main goroutine. This can be
+// used to prevent race conditions from delayed functions
+func QueueFunc(fn func()) {
+ MsgChannel <- &AercFuncMsg{Func: fn}
+}
+
// dirty is the dirty state of the UI. Any value other than 0 means the UI is in
// a dirty state. Dirty should only be accessed via atomic operations to
// maintain thread safety