pbacsko commented on code in PR #589:
URL: https://github.com/apache/yunikorn-core/pull/589#discussion_r1269500664


##########
pkg/events/event_ringbuffer.go:
##########
@@ -116,9 +116,20 @@ func min(a, b uint64) uint64 {
        return m
 }
 
-// GetLastEventID returns the value of the unique id counter
+// GetLastEventID returns the value of the unique id counter.
+// If the buffer is empty, it returns 0.
 func (e *eventRingBuffer) GetLastEventID() uint64 {
-       return e.id
+       e.RLock()
+       defer e.RUnlock()
+       return e.getLastEventID()
+}
+
+// unlocked version of GetLastEventID()
+func (e *eventRingBuffer) getLastEventID() uint64 {
+       if e.id == 0 {
+               return 0

Review Comment:
   Special case: no events at all (no queues, no apps, no nodes). It will never 
happen in real life (we can't return -1 due to "id" being uint64).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to