Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: document that calling LockOSThread in init will lock main to m0 (the first OS thread) #23112
Continued from a brief in-person discussion with Ian and Keith earlier today.
A lot of people (including myself) want to write GUI programs in Go; we even had
Various components in Cocoa have internal consistency checks to make sure they are only ever called on the "main thread"; a program will abort if these checks fail.
In runtime-speak, the first thread created by the OS is called
On other platforms, we could just insert a
So far, the most widely used workaround has been to call
I wouldn't know if this should be documented in package runtime (under LockOSThread) or in the spec (as part of the definition of initialization behavior).
Furthermore, there's the potential that a different package's
And of course, all bets are off if another function in
The guarantee in question is provided by https://golang.org/cl/5309070. In the discussion on that CL there were suggestions that should only be done in the implementation, not the spec. At this point I think that perhaps we can document it in the runtime package. CC @rsc .