Skip to content
Snippets Groups Projects
Commit 34d08063 authored by Jonah Husson's avatar Jonah Husson
Browse files

fix initcreator test

parent 8df8ef75
No related branches found
No related tags found
2 merge requests!21Release,!18Batched notification
...@@ -7,8 +7,6 @@ import ( ...@@ -7,8 +7,6 @@ import (
"sync/atomic" "sync/atomic"
) )
type NotificationBuffer struct { type NotificationBuffer struct {
bufMap atomic.Value bufMap atomic.Value
counter *int64 counter *int64
...@@ -16,9 +14,13 @@ type NotificationBuffer struct { ...@@ -16,9 +14,13 @@ type NotificationBuffer struct {
func NewNotificationBuffer() *NotificationBuffer { func NewNotificationBuffer() *NotificationBuffer {
u := int64(0) u := int64(0)
return &NotificationBuffer{ sm := sync.Map{}
nb := &NotificationBuffer{
counter: &u, counter: &u,
bufMap: atomic.Value{},
} }
nb.bufMap.Store(&sm)
return nb
} }
func (bnm *NotificationBuffer) Swap(maxNotifications uint) map[int64][]*pb.NotificationData { func (bnm *NotificationBuffer) Swap(maxNotifications uint) map[int64][]*pb.NotificationData {
...@@ -51,4 +53,3 @@ func (bnm *NotificationBuffer)Add(n *pb.NotificationData){ ...@@ -51,4 +53,3 @@ func (bnm *NotificationBuffer)Add(n *pb.NotificationData){
c := atomic.AddInt64(bnm.counter, 1) c := atomic.AddInt64(bnm.counter, 1)
bnm.bufMap.Load().(*sync.Map).Store(strconv.FormatInt(c, 16), n) bnm.bufMap.Load().(*sync.Map).Store(strconv.FormatInt(c, 16), n)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment