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

Open
msoedov opened this issue May 8, 2019 · 3 comments

Comments

@msoedov
Copy link
Contributor

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

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

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.

@beoran

This comment has been minimized.

Copy link

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.

@triztian

This comment has been minimized.

Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.