Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: no examples for LockOSThread and UnlockOSThread #31911

msoedov opened this issue May 8, 2019 · 4 comments

runtime: no examples for LockOSThread and UnlockOSThread #31911

msoedov opened this issue May 8, 2019 · 4 comments
Documentation help wanted NeedsInvestigation


Copy link

@msoedov msoedov commented May 8, 2019

What version of Go are you using (go version)?

$ go version

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

What did you expect to see?

What did you see instead?

@ianlancetaylor ianlancetaylor changed the title No examples in documentation for runtime.LockOSThread and runtime.UnlockOSThread() runtime: no examples for LockOSThread and UnlockOSThread May 8, 2019
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone May 8, 2019
Copy link

@ianlancetaylor ianlancetaylor commented May 8, 2019

These are not easy functions to write good examples for. This might be better suited for a blog post. But if someone has a good idea for how to present these functions in a way that helps people use them correctly and meaningfully, go for it.

@andybons andybons added the NeedsInvestigation label May 8, 2019
Copy link

@beoran beoran commented May 9, 2019

These function are essential for doing GUI and graphic programming on many OS, because on many systems, only the first main thread may interact with the GUI or the OS's graphics subsystem.

In general, I feel that Go needs to focus not only on being a back end language but also more on native development. An official go lang blog post on the topic, with descriptions of LockOsThread and UnlockOsThread included would be very welcome indeed, and time permitting, I would certainly like to help proofread or smake suggestions for such a post.

Copy link

@triztian triztian commented May 31, 2019

@ianlancetaylor I think a good example is for ensuring execution on the main thread which is often required when integrating with platform specific UI libraries or say WebKit's JavaScriptCore component.

On those situations one would have to "acquire" the main thread early in the application's startup (the main func) and then execute the rest of the code in a goroutine that is not on the main thread.

Actually I think that the example provided in the Wiki is a great one:

Perhaps adding such link to the doc.go of the LockOSThread sources would suffice?

Copy link

@odeke-em odeke-em commented Oct 16, 2019

Thank you for raising this reference @triztian that's in the wiki! Good points @beoran about also native development, @eliasnaur presented at Gophercon 2019

@eliasnaur @hyangah if y'all are free and have bandwidth, might you be interested in an official blog post showing how to use these functions as Ian suggested? Please don't feel obligated to do this, I just figured you are both are domain experts :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Documentation help wanted NeedsInvestigation
None yet

No branches or pull requests

7 participants