|
@@ -13,7 +13,7 @@ import (
|
|
|
// This table is particularly useful for un/marking and checking values
|
|
|
// in different goroutines.
|
|
|
type StatusTable struct {
|
|
|
- lock sync.RWMutex
|
|
|
+ sync.RWMutex
|
|
|
pool map[string]bool
|
|
|
}
|
|
|
|
|
@@ -26,24 +26,24 @@ func NewStatusTable() *StatusTable {
|
|
|
|
|
|
// Start sets value of given name to true in the pool.
|
|
|
func (p *StatusTable) Start(name string) {
|
|
|
- p.lock.Lock()
|
|
|
- defer p.lock.Unlock()
|
|
|
+ p.Lock()
|
|
|
+ defer p.Unlock()
|
|
|
|
|
|
p.pool[name] = true
|
|
|
}
|
|
|
|
|
|
// Stop sets value of given name to false in the pool.
|
|
|
func (p *StatusTable) Stop(name string) {
|
|
|
- p.lock.Lock()
|
|
|
- defer p.lock.Unlock()
|
|
|
+ p.Lock()
|
|
|
+ defer p.Unlock()
|
|
|
|
|
|
p.pool[name] = false
|
|
|
}
|
|
|
|
|
|
// IsRunning checks if value of given name is set to true in the pool.
|
|
|
func (p *StatusTable) IsRunning(name string) bool {
|
|
|
- p.lock.RLock()
|
|
|
- defer p.lock.RUnlock()
|
|
|
+ p.RLock()
|
|
|
+ defer p.RUnlock()
|
|
|
|
|
|
return p.pool[name]
|
|
|
}
|