I've been experimenting with graphics programming using go+sdl2 for awhile now. I've always been uncertain how to deal with locking a goroutine to the main thread. MacOS requires interactions with the OS window to come from the main thread.
So far, I have something like this (pseudocode): func main() { cmds := make(chan func()) go func() { cmds <- func() { // this function runs on the main thread // and accesses the GPU via the global OpenGL state. gl.Draw() } }() runtime.LockOSThread() win := createWindow() for cmd := range cmds { cmd() } } I'd really love to get that LockOSThread call out of the main function and hide it away inside a library along with the other internal implementation details. Is that possible? As far as I can tell, it's not possible to ensure that a goroutine runs on the main thread without locking it directly from the main() function. Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e0e9ccf4-19c0-4e16-85fb-03734dc338a1%40googlegroups.com.