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

Function TestLatchWait

asyncbuffer/latch_test.go:44–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestLatchWait(t *testing.T) {
45 latch := asyncbuffer.NewLatch()
46
47 // Start a goroutine that will wait
48 waitCompleted := make(chan bool, 1)
49 go func() {
50 latch.Wait()
51 waitCompleted <- true
52 }()
53
54 // Give the goroutine a moment to start waiting
55 time.Sleep(10 * time.Millisecond)
56
57 // Wait should not complete yet
58 select {
59 case <-waitCompleted:
60 t.Fatal("Wait should not complete before Release")
61 default:
62 // Expected
63 }
64
65 // Release the latch
66 latch.Release()
67
68 // Wait should complete now
69 select {
70 case <-waitCompleted:
71 // Expected
72 case <-time.After(100 * time.Millisecond):
73 t.Fatal("Wait should complete after Release")
74 }
75}
76
77func TestLatchMultipleWaiters(t *testing.T) {
78 latch := asyncbuffer.NewLatch()

Callers

nothing calls this directly

Calls 3

WaitMethod · 0.95
ReleaseMethod · 0.95
NewLatchFunction · 0.92

Tested by

no test coverage detected