mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
refact: refactored module SetRunning method (fixes #49)
This commit is contained in:
parent
76d6977967
commit
9c6eb70eb3
15 changed files with 103 additions and 174 deletions
|
@ -80,8 +80,7 @@ func (t *Ticker) Start() error {
|
|||
return err
|
||||
}
|
||||
|
||||
t.SetRunning(true)
|
||||
go func() {
|
||||
return t.SetRunning(true, func() {
|
||||
log.Info("Ticker running with period %.fs.", t.Period.Seconds())
|
||||
tick := time.Tick(t.Period)
|
||||
for _ = range tick {
|
||||
|
@ -95,15 +94,9 @@ func (t *Ticker) Start() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (t *Ticker) Stop() error {
|
||||
if t.Running() == false {
|
||||
return session.ErrAlreadyStopped
|
||||
}
|
||||
t.SetRunning(false)
|
||||
return nil
|
||||
return t.SetRunning(false, nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue