To a SongList a method UpdateCurrentMaxListeners() was added, it checks and updates max listeners for a current song in a thread safe manner.
This commit is contained in:
parent
b659464118
commit
eeadbc4f96
@ -86,6 +86,16 @@ func (sl *SongList) Current() *Song {
|
||||
return &sl.current
|
||||
}
|
||||
|
||||
// UpdateCurrentMaxListeners checks and updates a maximal number of listeners
|
||||
// for a current song.
|
||||
func (sl *SongList) UpdateCurrentMaxListeners(listeners int) {
|
||||
sl.Lock()
|
||||
defer sl.Unlock()
|
||||
if listeners > sl.current.MaxListeners {
|
||||
sl.current.MaxListeners = listeners
|
||||
}
|
||||
}
|
||||
|
||||
// List returns a list of lastly played songs.
|
||||
func (sl *SongList) List() []Song {
|
||||
sl.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user