Added methods for a ListenerCounter struct to access a current peak and overall numbers of listeners.
This commit is contained in:
parent
08203c4be0
commit
4feeb518fc
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user