fix: #686 - concurrent map read and write
This commit is contained in:
parent
2a6d9e4f68
commit
294e33d110
|
|
@ -60,10 +60,16 @@ func GetAll() *variableBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEntities() entitiesByClass {
|
func GetEntities() entitiesByClass {
|
||||||
|
rwmutex.RLock()
|
||||||
|
defer rwmutex.RUnlock()
|
||||||
|
|
||||||
return contents.Entities
|
return contents.Entities
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEntityInstances(entityName string) entityInstancesByKey {
|
func GetEntityInstances(entityName string) entityInstancesByKey {
|
||||||
|
rwmutex.RLock()
|
||||||
|
defer rwmutex.RUnlock()
|
||||||
|
|
||||||
if entities, ok := contents.Entities[entityName]; ok {
|
if entities, ok := contents.Entities[entityName]; ok {
|
||||||
return entities
|
return entities
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ func ParseTemplateWithArgs(source string, ent *Entity, args map[string]string) s
|
||||||
}
|
}
|
||||||
|
|
||||||
templateVariables := &variableBase{
|
templateVariables := &variableBase{
|
||||||
OliveTin: contents.OliveTin,
|
OliveTin: GetAll().OliveTin,
|
||||||
Arguments: args,
|
Arguments: args,
|
||||||
CurrentEntity: entdata,
|
CurrentEntity: entdata,
|
||||||
}
|
}
|
||||||
|
|
@ -126,5 +126,8 @@ func ParseTemplateBoolWith(source string, ent *Entity) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClearEntities(entityType string) {
|
func ClearEntities(entityType string) {
|
||||||
|
rwmutex.Lock()
|
||||||
|
defer rwmutex.Unlock()
|
||||||
|
|
||||||
delete(contents.Entities, entityType)
|
delete(contents.Entities, entityType)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue