Fixed var naming in ListenerCounter.
This commit is contained in:
parent
00bac090bc
commit
a8a9a991d4
@ -10,8 +10,8 @@ import (
|
||||
// ListenerCounter stores the current, overall and peak numbers of listeners.
|
||||
type ListenerCounter struct {
|
||||
sync.RWMutex
|
||||
current, peak int64
|
||||
overall, cur_peak int64
|
||||
current, currentPeak int64
|
||||
overall, peak int64
|
||||
}
|
||||
|
||||
// NewListenerCounter returns a new ListenerCounter struct instance.
|
||||
@ -31,7 +31,7 @@ func (l *ListenerCounter) Peak() int64 {
|
||||
|
||||
// CurrentPeak returns a peak number of listeners for a currently playing song.
|
||||
func (l *ListenerCounter) CurrentPeak() int64 {
|
||||
return l.cur_peak
|
||||
return l.currentPeak
|
||||
}
|
||||
|
||||
// Overall returns an overall number of listeners for a currently playing song.
|
||||
@ -46,12 +46,12 @@ func (l *ListenerCounter) Inc() int64 {
|
||||
panic("a current number of listeners exceeded MaxInt64")
|
||||
}
|
||||
l.current++
|
||||
if l.current > l.currentPeak {
|
||||
l.currentPeak = l.current
|
||||
}
|
||||
if l.current > l.peak {
|
||||
l.peak = l.current
|
||||
}
|
||||
if l.current > l.cur_peak {
|
||||
l.cur_peak = l.current
|
||||
}
|
||||
if l.overall == math.MaxInt64 {
|
||||
panic("an overall number of listeners exceeded MaxInt64")
|
||||
}
|
||||
@ -72,9 +72,9 @@ func (l *ListenerCounter) Dec() (int64, error) {
|
||||
// Reset current peak and overall listeners for a song that is playing.
|
||||
// And return its values.
|
||||
func (l *ListenerCounter) Reset() (overall, peak int64) {
|
||||
peak = l.cur_peak
|
||||
l.cur_peak = l.current
|
||||
peak = l.peak
|
||||
overall = l.overall
|
||||
l.peak = l.current
|
||||
l.overall = l.current
|
||||
return
|
||||
}
|
||||
@ -82,12 +82,12 @@ func (l *ListenerCounter) Reset() (overall, peak int64) {
|
||||
func (l *ListenerCounter) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(&struct {
|
||||
Current int64 `json:"current"`
|
||||
CurPeak int64 `json:"current_peak"`
|
||||
Peak int64 `json:"peak"`
|
||||
Overall int64 `json:"overall"`
|
||||
CurPeak int64 `json:"current_peak"`
|
||||
}{
|
||||
Current: l.current,
|
||||
CurPeak: l.currentPeak,
|
||||
Peak: l.peak,
|
||||
Overall: l.overall,
|
||||
CurPeak: l.cur_peak})
|
||||
Overall: l.overall})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user