diff --git a/internal/thread/thread.go b/internal/thread/thread.go index fa6c62105..339523fc8 100644 --- a/internal/thread/thread.go +++ b/internal/thread/thread.go @@ -22,7 +22,6 @@ import ( type Thread struct { funcs chan func() error results chan error - closed chan struct{} } // New creates a new thread. @@ -32,7 +31,6 @@ func New() *Thread { return &Thread{ funcs: make(chan func() error), results: make(chan error), - closed: make(chan struct{}), } } @@ -40,9 +38,6 @@ func New() *Thread { // // Loop must be called on the thread. func (t *Thread) Loop(context context.Context) { - defer close(t.closed) - defer close(t.results) - defer close(t.funcs) loop: for { select { @@ -60,10 +55,6 @@ loop: // // Call panics when Loop already ends. func (t *Thread) Call(f func() error) error { - select { - case t.funcs <- f: - return <-t.results - case <-t.closed: - panic("thread: this thread is already terminated") - } + t.funcs <- f + return <-t.results }