mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-15 17:40:51 +00:00
remove export publisher, pooler
This commit is contained in:
parent
83dccb483b
commit
717c738583
@ -6,17 +6,17 @@ type observer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Publisher defines methods that support observers
|
// Publisher defines methods that support observers
|
||||||
type Publisher struct {
|
type publisher struct {
|
||||||
observerList []observer
|
observerList []observer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register adds an observer to observerList
|
// Register adds an observer to observerList
|
||||||
func (p *Publisher) Register(o observer) {
|
func (p *publisher) Register(o observer) {
|
||||||
p.observerList = append(p.observerList, o)
|
p.observerList = append(p.observerList, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deregister removes an observer from observerList
|
// Deregister removes an observer from observerList
|
||||||
func (p *Publisher) Deregister(o observer) {
|
func (p *publisher) Deregister(o observer) {
|
||||||
var indexToRemove int
|
var indexToRemove int
|
||||||
|
|
||||||
for i, observer := range p.observerList {
|
for i, observer := range p.observerList {
|
||||||
@ -30,7 +30,7 @@ func (p *Publisher) Deregister(o observer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify updates observers of any changes
|
// notify updates observers of any changes
|
||||||
func (p *Publisher) notify(subject string) {
|
func (p *publisher) notify(subject string) {
|
||||||
for _, observer := range p.observerList {
|
for _, observer := range p.observerList {
|
||||||
observer.OnUpdate(subject)
|
observer.OnUpdate(subject)
|
||||||
}
|
}
|
||||||
@ -38,20 +38,20 @@ func (p *Publisher) notify(subject string) {
|
|||||||
|
|
||||||
// Pooler continuously polls the dirty paramters
|
// Pooler continuously polls the dirty paramters
|
||||||
// it is expected to be run in a goroutine
|
// it is expected to be run in a goroutine
|
||||||
type Pooler struct {
|
type pooler struct {
|
||||||
run bool
|
run bool
|
||||||
Publisher
|
publisher
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPooler() *Pooler {
|
func newPooler() *pooler {
|
||||||
p := &Pooler{
|
p := &pooler{
|
||||||
run: true,
|
run: true,
|
||||||
}
|
}
|
||||||
go p.runner()
|
go p.runner()
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pooler) runner() {
|
func (p *pooler) runner() {
|
||||||
for p.run {
|
for p.run {
|
||||||
if pdirty() {
|
if pdirty() {
|
||||||
p.notify("pdirty")
|
p.notify("pdirty")
|
||||||
|
@ -15,7 +15,7 @@ type remote struct {
|
|||||||
Command *command
|
Command *command
|
||||||
Vban *vban
|
Vban *vban
|
||||||
|
|
||||||
Pooler *Pooler
|
pooler *pooler
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the fmt.stringer interface
|
// String implements the fmt.stringer interface
|
||||||
@ -26,14 +26,14 @@ func (r *remote) String() string {
|
|||||||
// Login logs into the API
|
// Login logs into the API
|
||||||
// then it intializes the pooler
|
// then it intializes the pooler
|
||||||
func (r *remote) Login() {
|
func (r *remote) Login() {
|
||||||
r.Pooler = newPooler()
|
r.pooler = newPooler()
|
||||||
login(r.kind.name)
|
login(r.kind.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logout logs out of the API
|
// Logout logs out of the API
|
||||||
// it also terminates the pooler
|
// it also terminates the pooler
|
||||||
func (r *remote) Logout() {
|
func (r *remote) Logout() {
|
||||||
r.Pooler.run = false
|
r.pooler.run = false
|
||||||
logout()
|
logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ func (r *remote) SendText(script string) {
|
|||||||
|
|
||||||
// Register forwards the register method to Pooler
|
// Register forwards the register method to Pooler
|
||||||
func (r *remote) Register(o observer) {
|
func (r *remote) Register(o observer) {
|
||||||
r.Pooler.Register(o)
|
r.pooler.Register(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register forwards the deregister method to Pooler
|
// Register forwards the deregister method to Pooler
|
||||||
func (r *remote) Deregister(o observer) {
|
func (r *remote) Deregister(o observer) {
|
||||||
r.Pooler.Deregister(o)
|
r.pooler.Deregister(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
type remoteBuilder interface {
|
type remoteBuilder interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user