Almost all graphics systems are single threaded. Some allow additional non 
rendering event loops but with heavy restrictions that GUI components are only 
accessed on the main event loop thread. 

> On Oct 3, 2023, at 2:00 AM, 'wagner riffel' via golang-nuts 
> <golang-nuts@googlegroups.com> wrote:
> 
> On Tue Oct 3, 2023 at 05:54 AM UTC, Kurtis Rader wrote:
> > Thank you to Ian and TheDiveO. I don't understand why functions like
> > gocv.io/x/gocv.NewWindow() have to run on the initial OS thread (at least
> > on macOS).
> 
> It's common for C and C++ libraries to use TLS (thread local storage)
> to attach data/state to each thread, one example is the global errno
> variable used in C to signal errors, each thread read/write its own
> variable even though in code they are wirting "the same" variable,
> using libc from cgo and reading errno for failures would give wrong
> results if the goroutine moved OS threads. It's unrelated which thread
> it is and that's why it's not a default, you could start NewWindow at
> some point that its goroutine is running in thread4, and if it's not
> pinned to run in thread4 you have the same issue with the "initial
> thread".
> 
> ps: Specific with graphics, I know OpenGL retains thread-local data,
> which might explain why libraries that have this common ancestor needs
> to LockOSThread, I'm not sure about Mac and Windows.
> 
> -w
> 
> -- 
> 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/dcbc6ba0-54c8-5942-eb4d-120ba8d65f03%40104d.net.

-- 
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/DD240547-61CF-40AC-9DDC-C49504203FB4%40ix.netcom.com.

Reply via email to