mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
This commit implements cancelable reads, which allows Bubble Tea programs to run in succession in a single application. It also makes sure all goroutines terminate before `Program.Start()` returns. Closes #24.
21 lines
670 B
Go
21 lines
670 B
Go
//go:build solaris
|
|
// +build solaris
|
|
|
|
// nolint:revive
|
|
package tea
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// newCancelReader returns a reader and a cancel function. If the input reader
|
|
// is an *os.File, the cancel function can be used to interrupt a blocking call
|
|
// read call. In this case, the cancel function returns true if the call was
|
|
// cancelled successfully. If the input reader is not a *os.File or the file
|
|
// descriptor is 1024 or larger, the cancel function does nothing and always
|
|
// returns false. The generic unix implementation is based on the posix select
|
|
// syscall.
|
|
func newCancelReader(reader io.Reader) (cancelReader, error) {
|
|
return newSelectCancelReader(reader)
|
|
}
|