use pointers
Some checks failed
Build and Publish / BuildAndDeploy (push) Has been cancelled

This commit is contained in:
matst80
2024-11-10 13:49:11 +01:00
parent ff5c21aab2
commit 4846052bed

View File

@@ -12,7 +12,7 @@ import (
type RemoteGrainPool struct {
mu sync.RWMutex
Host string
grains map[CartId]RemoteGrain
grains map[CartId]*RemoteGrain
}
func (id CartId) String() string {
@@ -99,7 +99,7 @@ func (g *RemoteGrain) GetCurrentState() ([]byte, error) {
func NewRemoteGrainPool(addr string) *RemoteGrainPool {
return &RemoteGrainPool{
Host: addr,
grains: make(map[CartId]RemoteGrain),
grains: make(map[CartId]*RemoteGrain),
}
}
@@ -111,7 +111,7 @@ func (p *RemoteGrainPool) findRemoteGrain(id CartId) *RemoteGrain {
return nil
}
grain.Connect()
return &grain
return grain
}
func (p *RemoteGrainPool) findOrCreateGrain(id CartId) *RemoteGrain {
@@ -119,7 +119,7 @@ func (p *RemoteGrainPool) findOrCreateGrain(id CartId) *RemoteGrain {
if grain == nil {
grain = NewRemoteGrain(id, p.Host)
p.mu.Lock()
p.grains[id] = *grain
p.grains[id] = grain
p.mu.Unlock()
grain.Connect()
}