11# mainthread [ ![ PkgGoDev] ( https://pkg.go.dev/badge/golang.design/x/mainthread )] ( https://pkg.go.dev/golang.design/x/mainthread ) ![ mainthread] ( https://github.com/golang-design/mainthread/workflows/mainthread/badge.svg?branch=main ) ![ ] ( https://changkun.de/urlstat?mode=github&repo=golang-design/mainthread )
22
3- schedules function to run on the main thread
3+ schedule functions to run on the main thread
44
55``` go
66import " golang.design/x/mainthread"
@@ -15,7 +15,7 @@ import "golang.design/x/mainthread"
1515
1616Package mainthread offers facilities to schedule functions
1717on the main thread. To use this package properly, one must
18- call mainthread.Init from the main package. For example:
18+ call ` mainthread.Init ` from the main package. For example:
1919
2020``` go
2121package main
@@ -26,18 +26,20 @@ func main() { mainthread.Init(fn) }
2626
2727// fn is the actual main function
2828func fn () {
29- // mainthread.Call returns when f1 returns. Note that if f1 blocks
30- // it will also block the execution of any subsequent calls on the
31- // main thread.
32- mainthread.Call (f1)
29+ // ... do whatever you want to do ...
3330
34- // ... do whatever you want to do ...
31+ // mainthread.Call returns when f1 returns. Note that if f1 blocks
32+ // it will also block the execution of any subsequent calls on the
33+ // main thread.
34+ mainthread.Call (f1)
3535
36- // mainthread.Go returns immediately and f2 is scheduled to be executed
37- // in the future.
38- mainthread.Go (f2)
36+ // ... do whatever you want to do ...
3937
40- // ... do whatever you want to do ...
38+ // mainthread.Go returns immediately and f2 is scheduled to be
39+ // executed in the future.
40+ mainthread.Go (f2)
41+
42+ // ... do whatever you want to do ...
4143}
4244
4345func f1 () { ... }
0 commit comments