mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-20 05:54:34 -04:00
docs(tracker): improve comments and formatting
This commit is contained in:
parent
8eb5f17f73
commit
28a0006b6a
@ -32,7 +32,6 @@ type (
|
|||||||
// case <-FinishedXXX:
|
// case <-FinishedXXX:
|
||||||
// case <-time.After(3 * time.Second):
|
// case <-time.After(3 * time.Second):
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Broker struct {
|
Broker struct {
|
||||||
ToModel chan MsgToModel
|
ToModel chan MsgToModel
|
||||||
ToPlayer chan any // TODO: consider using a sum type here, for a bit more type safety. See: https://www.jerf.org/iri/post/2917/
|
ToPlayer chan any // TODO: consider using a sum type here, for a bit more type safety. See: https://www.jerf.org/iri/post/2917/
|
||||||
@ -85,6 +84,10 @@ type (
|
|||||||
HasOversampling bool
|
HasOversampling bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MsgToGUI is a message sent to the GUI, as GUI stores part of the state.
|
||||||
|
// In particular, GUI knows about where lists / tables are centered, so the
|
||||||
|
// kind of messages we send to the GUI are about centering the view on a
|
||||||
|
// specific row, or ensuring that the cursor is visible.
|
||||||
MsgToGUI struct {
|
MsgToGUI struct {
|
||||||
Kind GUIMessageKind
|
Kind GUIMessageKind
|
||||||
Param int
|
Param int
|
||||||
@ -101,7 +104,7 @@ const (
|
|||||||
|
|
||||||
func NewBroker() *Broker {
|
func NewBroker() *Broker {
|
||||||
return &Broker{
|
return &Broker{
|
||||||
ToPlayer: make(chan interface{}, 1024),
|
ToPlayer: make(chan any, 1024),
|
||||||
ToModel: make(chan MsgToModel, 1024),
|
ToModel: make(chan MsgToModel, 1024),
|
||||||
ToDetector: make(chan MsgToDetector, 1024),
|
ToDetector: make(chan MsgToDetector, 1024),
|
||||||
ToGUI: make(chan any, 1024),
|
ToGUI: make(chan any, 1024),
|
||||||
@ -109,7 +112,7 @@ func NewBroker() *Broker {
|
|||||||
CloseGUI: make(chan struct{}, 1),
|
CloseGUI: make(chan struct{}, 1),
|
||||||
FinishedGUI: make(chan struct{}),
|
FinishedGUI: make(chan struct{}),
|
||||||
FinishedDetector: make(chan struct{}),
|
FinishedDetector: make(chan struct{}),
|
||||||
bufferPool: sync.Pool{New: func() interface{} { return &sointu.AudioBuffer{} }},
|
bufferPool: sync.Pool{New: func() any { return &sointu.AudioBuffer{} }},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,10 +146,10 @@ func (b *Broker) PutAudioBuffer(buf *sointu.AudioBuffer) {
|
|||||||
func TrySend[T any](c chan<- T, v T) bool {
|
func TrySend[T any](c chan<- T, v T) bool {
|
||||||
select {
|
select {
|
||||||
case c <- v:
|
case c <- v:
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeoutReceive is a helper function to block until a value is received from a
|
// TimeoutReceive is a helper function to block until a value is received from a
|
||||||
|
Reference in New Issue
Block a user