Skip to content

Commit

Permalink
update timer
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya committed Oct 17, 2015
1 parent 8ebf549 commit 90f8bdf
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/spider/common/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func (self *CountdownTimer) Wait(routine string) {
}

func (self *CountdownTimer) Update(routine string) {
self.RWMutex.RLock()
defer self.RWMutex.RUnlock()
if _, ok := self.Routines[routine]; !ok {
return
}
go func() {
defer func() {
recover()
Expand All @@ -108,14 +113,21 @@ func (self *CountdownTimer) Update(routine string) {
}()
}

func (self *CountdownTimer) AddRoutine(routine string, t float64) *CountdownTimer {
func (self *CountdownTimer) SetRoutine(routine string, t float64) *CountdownTimer {
self.RWMutex.Lock()
defer self.RWMutex.Unlock()
self.Routines[routine] = t
return self
}

func (self *CountdownTimer) ReSetLevel(level []float64) *CountdownTimer {
func (self *CountdownTimer) RemoveRoutine(routine string) *CountdownTimer {
self.RWMutex.Lock()
defer self.RWMutex.Unlock()
delete(self.Routines, routine)
return self
}

func (self *CountdownTimer) SetLevel(level []float64) *CountdownTimer {
self.RWMutex.Lock()
defer self.RWMutex.Unlock()
self.Level = level
Expand Down

0 comments on commit 90f8bdf

Please sign in to comment.