MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestRapidTicksAndWaits

Method TestRapidTicksAndWaits

asyncbuffer/cond_test.go:107–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105}
106
107func (s *TestCondSuite) TestRapidTicksAndWaits() {
108 const iterations = 1000
109
110 var wg sync.WaitGroup
111
112 // Start a goroutine that will rapidly tick
113 wg.Go(func() {
114 timeTicker := time.Tick(time.Microsecond)
115
116 for range iterations {
117 <-timeTicker
118 s.cond.Tick()
119 }
120
121 s.cond.Close() // Close after all ticks
122 })
123
124 // Start multiple waiters
125 for range 10 {
126 wg.Go(func() {
127 cursor := s.cond.Cursor()
128 for range iterations / 10 {
129 cursor = s.cond.Wait(cursor)
130 }
131 })
132 }
133
134 var done atomic.Bool
135 go func() {
136 wg.Wait()
137 done.Store(true)
138 }()
139
140 s.Require().Eventually(done.Load, 200*time.Millisecond, 10*time.Millisecond)
141}
142
143func TestCond(t *testing.T) {
144 suite.Run(t, new(TestCondSuite))

Callers

nothing calls this directly

Calls 4

TickMethod · 0.80
CursorMethod · 0.80
CloseMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected