You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I am using cgo to wrap a library that creates an OSX UI, which requires things to be run on the "main thread". Sometimes my cgo calls end up on the main thread and sometimes they do not (I check this with [NSThread isMainThread]). I understand that cgo threads are guaranteed to run on an OS-allocated stack, but what does this mean w.r.t. the OSX "main thread"? Has anyone else faced this problem before?
Ian Lance Taylor
unread,
Sep 9, 2016, 1:57:24 PM9/9/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Alex Flint, golang-nuts
See https://golang.org/pkg/runtime/#LockOSThread . The goroutine that
runs the `main` function should be the main thread, so if you call
`LockOSThread` first thing and then do all your cgo calls from that
goroutine everything should be fine.
Ian
Martin Bertschler
unread,
Sep 9, 2016, 6:02:51 PM9/9/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
There is also a great wiki article on how to execute functions on the main thread from multiple goroutines. It helped me a lot when I did some GUI development experiments. https://github.com/golang/go/wiki/LockOSThread