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

Method TestBasicWaitAndTick

asyncbuffer/cond_test.go:31–52  ·  view source on GitHub ↗

TestBasicWaitAndTick tests the basic functionality of the Cond

()

Source from the content-addressed store, hash-verified

29
30// TestBasicWaitAndTick tests the basic functionality of the Cond
31func (s *TestCondSuite) TestBasicWaitAndTick() {
32 ch := asyncbuffer.CondCh(s.cond)
33
34 // Start a goroutine that will tick after a short delay
35 go func() {
36 time.Sleep(50 * time.Millisecond)
37 s.cond.Tick()
38 }()
39
40 // Start a goroutine that will wait for the tick
41 var done atomic.Bool
42 go func() {
43 cursor := s.cond.Cursor()
44 s.cond.Wait(cursor)
45 done.Store(true)
46 }()
47
48 s.Require().Eventually(done.Load, 200*time.Millisecond, 10*time.Millisecond)
49
50 // Means that and old channel was closed and a new one has been created
51 s.Require().NotEqual(ch, asyncbuffer.CondCh(s.cond))
52}
53
54// TestWaitMultipleWaiters tests that multiple waiters can be unblocked by a single tick
55func (s *TestCondSuite) TestWaitMultipleWaiters() {

Callers

nothing calls this directly

Calls 4

CondChFunction · 0.92
TickMethod · 0.80
CursorMethod · 0.80
WaitMethod · 0.45

Tested by

no test coverage detected