internal/mainthread/mainthread.go
func Loop(ch <-chan error) error {
	atomic.StoreInt32(&started, 1)
	for {
		select {
		case f := <-funcs:
			f()
		case err := <-ch:
			// ch returns a value not only when an error occur but also it is closed.
			return err
		}
	}
}
func Loop(ch <-chan error) error {
	atomic.StoreInt32(&started, 1)
	for {
		select {
		case f := <-funcs:
			f()
		case err := <-ch:
			// ch returns a value not only when an error occur but also it is closed.
			return err
		}
	}
}
// Loop starts the main-thread loop.
//
// Loop must be called on the main thread.