Skip to content

Commit f6d9bde

Browse files
committed
all: doc update
1 parent 29d6727 commit f6d9bde

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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
99
import "golang.design/x/mainthread"
@@ -17,19 +17,15 @@ package main
1717
import "golang.design/x/mainthread"
1818

1919
func 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

0 commit comments

Comments
 (0)