[#92] Embed policer's objectsInWork mutex

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
Alejandro Lopez 2023-06-30 10:08:36 +03:00 committed by Evgenii Stratonikov
parent f9730f090d
commit 3223402c90

View file

@ -11,28 +11,28 @@ import (
)
type objectsInWork struct {
m sync.RWMutex
sync.RWMutex
objs map[oid.Address]struct{}
}
func (oiw *objectsInWork) inWork(addr oid.Address) bool {
oiw.m.RLock()
oiw.RLock()
_, ok := oiw.objs[addr]
oiw.m.RUnlock()
oiw.RUnlock()
return ok
}
func (oiw *objectsInWork) remove(addr oid.Address) {
oiw.m.Lock()
oiw.Lock()
delete(oiw.objs, addr)
oiw.m.Unlock()
oiw.Unlock()
}
func (oiw *objectsInWork) add(addr oid.Address) {
oiw.m.Lock()
oiw.Lock()
oiw.objs[addr] = struct{}{}
oiw.m.Unlock()
oiw.Unlock()
}
// Policer represents the utility that verifies