|
@@ -2,7 +2,6 @@ package ticker
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
- "fmt"
|
|
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -11,7 +10,7 @@ var _ Ticker = (*ticker)(nil)
|
|
type Ticker interface {
|
|
type Ticker interface {
|
|
worker()
|
|
worker()
|
|
|
|
|
|
- Process(fun any) error
|
|
|
|
|
|
+ Process(fun func())
|
|
Stop()
|
|
Stop()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -42,16 +41,9 @@ func (t *ticker) worker() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (t *ticker) Process(fun any) error {
|
|
|
|
- f, ok := fun.(func())
|
|
|
|
- if !ok {
|
|
|
|
- return fmt.Errorf("fun is not func")
|
|
|
|
- }
|
|
|
|
- t.f = f
|
|
|
|
-
|
|
|
|
|
|
+func (t *ticker) Process(fun func()) {
|
|
|
|
+ t.f = fun
|
|
go t.worker()
|
|
go t.worker()
|
|
-
|
|
|
|
- return nil
|
|
|
|
}
|
|
}
|
|
|
|
|
|
func (t *ticker) Stop() {
|
|
func (t *ticker) Stop() {
|