On Mon, Feb 13, 2017 at 1:14 PM,  <db0...@gmail.com> wrote:
> On Monday, February 13, 2017 at 7:02:22 AM UTC+1, Luka Napotnik wrote:
>>
>> I forgot to mention that the main goroutine in the test program is locked
>> to a thread as I call runtime.LockOSThread() in init()
>
>
> The Go Spec says "Package initialization—variable initialization and the
> invocation of init functions—happens in a single goroutine, sequentially,
> one package at a time. An init function may launch other goroutines, which
> can run concurrently with the initialization code.". The way I understand
> it, code in init() is not guaranteed to run in the same goroutine as main(),
> so you might be better of calling LockOSThread() from main() (or from
> whatever goroutine will do the GTK calls).

I think you're right that the spec does not guarantee that the same
goroutine runs init functions and the main function.  I'll just note
that in practice it is the same goroutine, for all the implementations
I know of.

Ian

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to