1
0

Added methods for a ListenerCounter struct to access a current peak and overall numbers of listeners.

This commit is contained in:
Alexander Andreev 2024-05-11 04:42:06 +04:00
parent 08203c4be0
commit 4feeb518fc
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

View File

@ -26,13 +26,27 @@ func (l *ListenerCounter) Current() int64 {
return l.current
}
// Current returns a number of peak listeners.
// Peak returns a peak number of listeners.
func (l *ListenerCounter) Peak() int64 {
l.mutex.RLock()
defer l.mutex.RUnlock()
return l.peak
}
// CurrentPeak returns a peak number of listeners for a currently playing song.
func (l *ListenerCounter) CurrentPeak() int64 {
l.mutex.RLock()
defer l.mutex.RUnlock()
return l.cur_peak
}
// Overall returns an overall number of listeners for a currently playing song.
func (l *ListenerCounter) Overall() int64 {
l.mutex.RLock()
defer l.mutex.RUnlock()
return l.overall
}
// Inc increments by 1 a current number of listeners and updates a peak number.
func (l *ListenerCounter) Inc() int64 {
l.mutex.Lock()