12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package sync
- import (
- "sync"
- )
- type StatusTable struct {
- sync.RWMutex
- pool map[string]bool
- }
- func NewStatusTable() *StatusTable {
- return &StatusTable{
- pool: make(map[string]bool),
- }
- }
- func (p *StatusTable) Start(name string) {
- p.Lock()
- defer p.Unlock()
- p.pool[name] = true
- }
- func (p *StatusTable) Stop(name string) {
- p.Lock()
- defer p.Unlock()
- p.pool[name] = false
- }
- func (p *StatusTable) IsRunning(name string) bool {
- p.RLock()
- defer p.RUnlock()
- return p.pool[name]
- }
|