]> code.octet-stream.net Git - broadcaster/blob - server/playlist.go
Simplify package names
[broadcaster] / server / playlist.go
1 package main
2
3 import (
4 "sync"
5 )
6
7 type Playlists struct {
8 changeWait chan bool
9 playlistMutex sync.Mutex
10 }
11
12 var playlists Playlists
13
14 func InitPlaylists() {
15 playlists.changeWait = make(chan bool)
16 }
17
18 func (p *Playlists) GetPlaylists() []Playlist {
19 p.playlistMutex.Lock()
20 defer p.playlistMutex.Unlock()
21 return db.GetPlaylists()
22 }
23
24 func (p *Playlists) WatchForChanges() ([]Playlist, chan bool) {
25 p.playlistMutex.Lock()
26 defer p.playlistMutex.Unlock()
27 return db.GetPlaylists(), p.changeWait
28 }
29
30 func (p *Playlists) NotifyChanges() {
31 p.playlistMutex.Lock()
32 defer p.playlistMutex.Unlock()
33 close(p.changeWait)
34 p.changeWait = make(chan bool)
35 }