go-study/lock_free/delay_queue_test.go

34 lines
504 B
Go
Raw Normal View History

package lock_free
import (
"testing"
"time"
)
func TestDelayLkQueue(t *testing.T) {
cases := []struct {
value int
duration time.Duration
}{
{1, time.Second},
{3, time.Second * 3},
}
q := NewDelayLkQueue[int]()
for _, c := range cases {
q.DelayEnqueue(c.value, c.duration)
}
2024-12-03 10:49:09 +08:00
notify := make(chan int)
go func() {
2024-12-03 10:49:09 +08:00
for data := range notify {
t.Log(data)
t.Log(time.Now().Unix())
}
}()
go q.ContinuousDequeueNotify(notify)
time.Sleep(time.Second * 5)
2024-12-03 10:49:09 +08:00
close(notify)
}