1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-12-15 08:16:43 +00:00

add files

This commit is contained in:
2019-03-04 17:19:55 +08:00
parent 5c500fca4e
commit aa2a233485
6 changed files with 216 additions and 0 deletions

29
src/resource_pool.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"sync"
)
type ResourcePool struct {
mu sync.Mutex
nodes map[int][]Status
}
func (pool *ResourcePool) update(node MsgAgent) {
pool.mu.Lock()
defer pool.mu.Unlock()
pool.nodes[node.ClientID] = node.Status
}
func (pool *ResourcePool) getByID(id int) []Status {
pool.mu.Lock()
defer pool.mu.Unlock()
status, ok := pool.nodes[id]
if ok {
return status
}
return []Status{}
}