File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ import "golang.design/x/mainthread"
1313
1414## API Usage
1515
16- Package mainthread offers facilities to schedule functions on the
17- main thread. To use this package properly, one must call
18- mainthread.Init from the main package. For example:
16+ Package mainthread offers facilities to schedule functions
17+ on the main thread. To use this package properly, one must
18+ call mainthread.Init from the main package. For example:
1919
2020``` go
2121package main
Original file line number Diff line number Diff line change 44//
55// Written by Changkun Ou <changkun.de>
66
7- // Package mainthread offers facilities to schedule functions on the
8- // main thread. To use this package properly, one must call
9- // mainthread.Init from the main package. For example:
7+ // Package mainthread offers facilities to schedule functions
8+ // on the main thread. To use this package properly, one must
9+ // call mainthread.Init from the main package. For example:
1010//
1111// package main
1212//
@@ -61,13 +61,9 @@ func Init(main func()) {
6161 for {
6262 select {
6363 case f := <- funcQ :
64- if f .fn != nil {
65- f .fn ()
66- if f .done != nil {
67- f .done <- struct {}{}
68- }
69- } else if f .fnv != nil {
70- f .ret <- f .fnv ()
64+ f .fn ()
65+ if f .done != nil {
66+ f .done <- struct {}{}
7167 }
7268 case <- done :
7369 return
9490 donePool = sync.Pool {New : func () interface {} {
9591 return make (chan struct {})
9692 }}
97- retPool = sync.Pool {New : func () interface {} {
98- return make (chan interface {})
99- }}
10093)
10194
10295type funcData struct {
10396 fn func ()
10497 done chan struct {}
105- fnv func () interface {}
106- ret chan interface {}
10798}
You can’t perform that action at this time.
0 commit comments