I've been getting by with a version of this that sends commands (closures) 
to a loop on the main thread:
https://github.com/buchanae/ink/blob/2af8781a960a0351b6b6b7ca23d81ae5c43535ec/win/window.go#L55

And here is where it pops those commands, and also integrates with the OS 
event loop:
https://github.com/buchanae/ink/blob/2af8781a960a0351b6b6b7ca23d81ae5c43535ec/win/window.go#L163

But, I'm still not satisfied. The solution ties together the scheduling 
(and code) of two separate event loops. In particular, I've found that my 
commands are delayed ~10ms – I think sdl.WaitEvent might be rate limited.

What I really want is for the two event loops (OS event loop vs app command 
loop) to be in two separate goroutines, both running on the main thread. 
That way, the OS event loop can react to infrequent window events (mouse 
clicks, etc) without burning lots of CPU, while my app command loop can 
react to commands instantly. 

Does that make sense? Is this possible to implement without requiring a 
change to the Go runtime? Is it possible to change the Go runtime to allow 
multiple goroutines to be scheduled only to the main thread?

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/e4e3a04d-0f76-4baf-9760-9992ef38d51f%40googlegroups.com.

Reply via email to