1
0

In song.go updated comments.

This commit is contained in:
Alexander Andreev 2023-10-09 00:05:28 +04:00
parent f960d8516a
commit fb46a912f7
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -39,6 +39,8 @@ func (s *Song) MarshalJSON() ([]byte, error) {
StartAt: s.StartAt.UTC().Format(time.RFC3339)}) StartAt: s.StartAt.UTC().Format(time.RFC3339)})
} }
// SongList holds a currently playing song and a list of previously played ones
// with a maximal length of maxLen.
type SongList struct { type SongList struct {
sync.RWMutex sync.RWMutex
current Song current Song
@ -69,7 +71,7 @@ func (sl *SongList) Add(newSong Song) {
sl.current = newSong sl.current = newSong
} }
// Current returns a currently playing song. // Current returns a currently playing song or nil if it isn't set yet.
func (sl *SongList) Current() *Song { func (sl *SongList) Current() *Song {
sl.RLock() sl.RLock()
defer sl.RUnlock() defer sl.RUnlock()
@ -101,7 +103,7 @@ func (sl *SongList) List() []Song {
return sl.lastSongs return sl.lastSongs
} }
// MaxLen returns a maximal length of a list // MaxLen returns a maximal length of a song list.
func (sl *SongList) MaxLen() int { func (sl *SongList) MaxLen() int {
return sl.maxLen return sl.maxLen
} }