Skip to content
Permalink
develop
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
package main
import "sync"
type StampedReading struct {
Timestamp int `json:"timestamp"`
Value interface{} `json:"value"`
}
type Packet struct {
ID int `json:"id"`
Kind string `json:"kind"`
Message []byte `json:"message"`
}
type StatusUpdates struct {
Timestamp int `json:"timestamp"`
Updates map[string]int `json:"updates"`
}
type generator struct {
databaseId int
serverSn string
socket *socketConn
}
type generatorMap struct {
lock sync.Mutex
mapping map[string]*generator
}
func newGenMap() *generatorMap {
return &generatorMap{sync.Mutex{}, make(map[string]*generator)}
}
func (g *generatorMap) add(k string, v *generator) {
g.lock.Lock()
defer g.lock.Unlock()
g.mapping[k] = v
}
type IDMap struct {
lock sync.Mutex
mapping map[int]string
}
func newIDMap() *IDMap {
return &IDMap{sync.Mutex{}, make(map[int]string)}
}
func (m *IDMap) add(k int, v string) {
m.lock.Lock()
defer m.lock.Unlock()
m.mapping[k] = v
}
// TODO: maybe break this up a bit