1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-12 22:10:39 +00:00

Move many PR's change here since the original authors are responseless

This commit is contained in:
Ming Deng
2020-06-23 21:18:58 +08:00
parent 96658121dc
commit 3ce68d6a30
5 changed files with 73 additions and 43 deletions

View File

@ -33,7 +33,7 @@ type bounds struct {
// The bounds for each field.
var (
AdminTaskList map[string]Tasker
taskLock sync.Mutex
taskLock sync.RWMutex
stop chan bool
changed chan bool
isstart bool
@ -408,7 +408,10 @@ func run() {
}
for {
// we only use RLock here because NewMapSorter copy the reference, do not change any thing
taskLock.RLock()
sortList := NewMapSorter(AdminTaskList)
taskLock.RUnlock()
sortList.Sort()
var effective time.Time
if len(AdminTaskList) == 0 || sortList.Vals[0].GetNext().IsZero() {
@ -432,9 +435,11 @@ func run() {
continue
case <-changed:
now = time.Now().Local()
taskLock.Lock()
for _, t := range AdminTaskList {
t.SetNext(now)
}
taskLock.Unlock()
continue
case <-stop:
return