go-study/lock_free/queues_test.go

35 lines
541 B
Go

package lock_free
import (
"testing"
"time"
)
func TestQueues(t *testing.T) {
cases := []struct {
value int
duration time.Duration
}{
{1, time.Second},
{3, time.Second * 3},
}
route := "test"
q := NewQueues[struct{}, int, string]()
for _, c := range cases {
q.DelayEnqueue(route, c.value, c.duration)
}
notify := make(chan int)
go func() {
for data := range notify {
t.Log(data)
t.Log(time.Now().Unix())
}
}()
go q.ContinuousDequeueNotify(route, notify)
time.Sleep(time.Second * 5)
close(notify)
}