MCPcopy Create free account
hub / github.com/eapache/channels / TestSharedBufferMultiple

Function TestSharedBufferMultiple

shared_buffer_test.go:33–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestSharedBufferMultiple(t *testing.T) {
34 buf := NewSharedBuffer(3)
35
36 ch1 := buf.NewChannel()
37 ch2 := buf.NewChannel()
38
39 ch1.In() <- (*int)(nil)
40 ch1.In() <- (*int)(nil)
41 ch1.In() <- (*int)(nil)
42
43 select {
44 case ch2.In() <- (*int)(nil):
45 t.Error("Wrote to full shared-buffer")
46 case <-ch2.Out():
47 t.Error("Read from empty channel")
48 default:
49 }
50
51 <-ch1.Out()
52
53 for i := 0; i < 10; i++ {
54 ch2.In() <- (*int)(nil)
55
56 select {
57 case ch1.In() <- (*int)(nil):
58 t.Error("Wrote to full shared-buffer")
59 case ch2.In() <- (*int)(nil):
60 t.Error("Wrote to full shared-buffer")
61 default:
62 }
63
64 <-ch2.Out()
65 }
66
67 <-ch1.Out()
68 <-ch1.Out()
69
70 ch1.Close()
71 ch2.Close()
72 buf.Close()
73}
74
75func TestSharedBufferConcurrent(t *testing.T) {
76 const threads = 10

Callers

nothing calls this directly

Calls 6

NewChannelMethod · 0.95
CloseMethod · 0.95
NewSharedBufferFunction · 0.85
InMethod · 0.65
OutMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…