只执行一次
This commit is contained in:
parent
d9484a75bc
commit
41bca1164d
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/fox/fox/log"
|
"github.com/fox/fox/log"
|
||||||
"github.com/fox/fox/safeChan"
|
"github.com/fox/fox/safeChan"
|
||||||
"github.com/fox/fox/timer"
|
"github.com/fox/fox/timer"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ type BaseService struct {
|
|||||||
*timer.Timer
|
*timer.Timer
|
||||||
type_ string
|
type_ string
|
||||||
name string
|
name string
|
||||||
|
once sync.Once
|
||||||
|
|
||||||
onFunc IOnFunc
|
onFunc IOnFunc
|
||||||
sender ISender
|
sender ISender
|
||||||
@ -174,7 +176,9 @@ func (s *BaseService) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *BaseService) Run() {
|
func (s *BaseService) Run() {
|
||||||
ksync.GoSafe(s.run, s.Run)
|
s.once.Do(func() {
|
||||||
|
ksync.GoSafe(s.run, s.run)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BaseService) Log(format string, a ...any) string {
|
func (s *BaseService) Log(format string, a ...any) string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user