diff --git a/coop.go b/coop.go index 2bd9f6e..8b3cb13 100644 --- a/coop.go +++ b/coop.go @@ -64,23 +64,6 @@ func Every(dur time.Duration, fn func()) { }) } -// Runs fn and times out if it runs longer than the provided -// duration. It will send false to the returning -// channel if timeout occurs. -// TODO: cancel if timeout occurs -func Timeout(duration time.Duration, fn func()) (done <-chan bool) { - ch := make(chan bool, 2) - go func() { - <-time.After(duration) - doneSig(ch, false) - }() - go func() { - fn() - doneSig(ch, true) - }() - return ch -} - // Starts to run the given list of fns concurrently. func All(fns ...func()) (done <-chan bool) { var wg sync.WaitGroup diff --git a/coop_test.go b/coop_test.go index aa6a34e..ee30036 100644 --- a/coop_test.go +++ b/coop_test.go @@ -86,24 +86,6 @@ func TestUntil_Past(test *testing.T) { } } -func TestTimeout_TimedOut(test *testing.T) { - done := Timeout(100*time.Millisecond, func() { - time.Sleep(time.Minute) - }) - if <-done { - test.Errorf("Expected to get timed out, but it has been completed") - } -} - -func TestTimeout_Completed(test *testing.T) { - done := Timeout(time.Minute, func() { - time.Sleep(100 * time.Millisecond) - }) - if !<-done { - test.Errorf("Expected to get completed, but it has been timed out") - } -} - func TestAll(test *testing.T) { start := time.Now() var val1, val2, val3 bool