1
0

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:
Alexander Andreev 2023-10-05 18:04:15 +04:00
parent b659464118
commit eeadbc4f96
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -86,6 +86,16 @@ func (sl *SongList) Current() *Song {
return &sl.current 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. // List returns a list of lastly played songs.
func (sl *SongList) List() []Song { func (sl *SongList) List() []Song {
sl.Lock() sl.Lock()