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:
29
src/resource_pool.go
Normal file
29
src/resource_pool.go
Normal 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{}
|
||||
}
|
||||
Reference in New Issue
Block a user