Skip to content

Commit

Permalink
remove internal/timerpool package
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Apr 19, 2024
1 parent 1db0e2b commit 669c0d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
34 changes: 0 additions & 34 deletions internal/timerpool/timerpool.go

This file was deleted.

14 changes: 2 additions & 12 deletions timing.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package rx

import (
"time"

"github.com/b97tsk/rx/internal/timerpool"
)
import "time"

// Ticker creates an Observable that emits [time.Time] values
// every specified interval of time.
Expand All @@ -15,12 +11,9 @@ func Ticker(d time.Duration) Observable[time.Time] {

return func(c Context, o Observer[time.Time]) {
tk := time.NewTicker(d)

c.Go(func() {
defer tk.Stop()

done := c.Done()

for {
select {
case <-done:
Expand All @@ -38,15 +31,12 @@ func Ticker(d time.Duration) Observable[time.Time] {
// after a particular time span has passed, and then completes.
func Timer(d time.Duration) Observable[time.Time] {
return func(c Context, o Observer[time.Time]) {
tm := timerpool.Get(d)

tm := time.NewTimer(d)
c.Go(func() {
select {
case <-c.Done():
timerpool.Put(tm)
o.Error(c.Cause())
case t := <-tm.C:
timerpool.PutExpired(tm)
Try1(o, Next(t), func() { o.Error(ErrOops) })
o.Complete()
}
Expand Down

0 comments on commit 669c0d3

Please sign in to comment.