diff --git a/eventstream/eventstream.go b/eventstream/eventstream.go index 3487b05f..290337cf 100644 --- a/eventstream/eventstream.go +++ b/eventstream/eventstream.go @@ -111,7 +111,9 @@ func (es *EventStream) Publish(evt interface{}) { // Returns an integer that represents the current number of subscribers to the stream func (es *EventStream) Length() int32 { - return atomic.LoadInt32(&es.counter) + es.RLock() + defer es.RUnlock() + return es.counter } // Subscription is returned from the Subscribe function.