- Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
ProposalProposal-Acceptedcompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Update The proposal is #64777 (comment).
Proposal Details
This proposal is a less flexible but perhaps easier to implement and maintain alternative to #64755. See that issue for background and motivation for non-main packages to take control of the main thread.
I propose adding a new function, runtime.RunOnMainThread, for running a function on the startup, or main, thread. In particular,
package runtime // RunOnMainThread runs a function immediately after program initialization on a // goroutine wired to the startup thread. It panics if called outside an init // function, if called more than once, or if [runtime.LockOSThread] has already // been called from an init function. // Once RunOnMainThread is called, later LockOSThread calls from an init function // will panic. func RunOnMainThread(f func())This is the complete proposal.
Variants
Just like #64755, an alternative spelling is syscall.RunOnMainThread optionally limited to GOOS=darwin and GOOS=ios.
hajimehoshi, Jacalz, eihigh, MatejMagat305, cristaloleg and 4 moreseankhliao, tmthrgd and ALX99
Metadata
Metadata
Assignees
Labels
ProposalProposal-Acceptedcompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
In Progress
Status
Accepted