1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 22:31:55 +00:00
YAO-scheduler/src/resource_pool.go

30 lines
412 B
Go
Raw Normal View History

2019-03-04 09:19:55 +00:00
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{}
}