File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change 33[ ![ PkgGoDev] ( https://pkg.go.dev/badge/golang.design/x/mainthread )] ( https://pkg.go.dev/golang.design/x/mainthread ) [ ![ Go Report Card] ( https://goreportcard.com/badge/golang.design/x/mainthread )] ( https://goreportcard.com/report/golang.design/x/mainthread )
44![ mainthread] ( https://github.com/golang-design/mainthread/workflows/mainthread/badge.svg?branch=main )
55
6- Package mainthread schedules function calls on the main thread in Go .
6+ Package mainthread schedules function to run on the main thread with zero allocation .
77
88``` go
99import " golang.design/x/mainthread"
@@ -17,19 +17,15 @@ package main
1717import " golang.design/x/mainthread"
1818
1919func main () {
20- mainthread.Init (func () {
21- mainthread.Call (func () {
22- // ... runs on the main thread ...
23- })
24-
25- go func () {
26- // ... runs concurrently ...
27- }()
28-
29- mainthread.Call (func () {
30- // ... runs on the main thread ...
31- })
20+ mainthread.Init (fn)
21+ }
22+
23+ func fn () {
24+ mainthread.Call (func () {
25+ // ... runs on the main thread ...
3226 })
27+
28+ // ... do what ever you want to do ...
3329}
3430```
3531
You can’t perform that action at this time.
0 commit comments