modify for unsafe

This commit is contained in:
zgfzgf 2020-09-25 22:13:27 +08:00
parent e5873d5dea
commit 60e950015c

View File

@ -417,6 +417,7 @@ func (sh *scheduler) trySched() {
// Step 2 // Step 2
scheduled := 0 scheduled := 0
rmQueue := make([]int, 0, sh.schedQueue.Len())
for sqi := 0; sqi < sh.schedQueue.Len(); sqi++ { for sqi := 0; sqi < sh.schedQueue.Len(); sqi++ {
task := (*sh.schedQueue)[sqi] task := (*sh.schedQueue)[sqi]
@ -453,11 +454,16 @@ func (sh *scheduler) trySched() {
windows[selectedWindow].todo = append(windows[selectedWindow].todo, task) windows[selectedWindow].todo = append(windows[selectedWindow].todo, task)
sh.schedQueue.Remove(sqi) rmQueue = append(rmQueue, sqi)
sqi--
scheduled++ scheduled++
} }
if len(rmQueue) > 0 {
for i := len(rmQueue) - 1; i >= 0; i++ {
sh.schedQueue.Remove(rmQueue[i])
}
}
// Step 3 // Step 3
if scheduled == 0 { if scheduled == 0 {