This commit is contained in:
2026-06-14 23:12:03 +03:00
parent 181031a753
commit b32279deaf
35 changed files with 1395 additions and 1062 deletions

View File

@@ -1,6 +1,8 @@
package inbox
import "sync"
import (
"sync"
)
type Inbox struct {
mutex *sync.Mutex
@@ -20,9 +22,11 @@ func (s *Inbox) Ready() chan struct{} {
}
func (s *Inbox) Push(x any) {
//fmt.Printf("inbox.Push: %#v\n", x)
s.mutex.Lock()
s.items = append(s.items, x)
s.mutex.Unlock()
//fmt.Printf("inbox.Pushed\n")
select {
case s.signalCh <- struct{}{}:
default:
@@ -30,9 +34,11 @@ func (s *Inbox) Push(x any) {
}
func (s *Inbox) Drain() []any {
//fmt.Printf("inbox.Drain\n")
s.mutex.Lock()
items := s.items
s.items = nil
s.mutex.Unlock()
//fmt.Printf("inbox.Drained: %#v\n", items)
return items
}