MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestOpenFilePool_Concurrent

Function TestOpenFilePool_Concurrent

internal/caches/open_file_pool_test.go:28–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestOpenFilePool_Concurrent(t *testing.T) {
29 var pool = caches.NewOpenFilePool("a")
30 var concurrent = 1000
31 var wg = &sync.WaitGroup{}
32 wg.Add(concurrent)
33 for i := 0; i < concurrent; i++ {
34 go func() {
35 defer wg.Done()
36
37 if rands.Int(0, 1) == 1 {
38 pool.Put(caches.NewOpenFile(nil, nil, nil, 0, 1))
39 }
40 if rands.Int(0, 1) == 0 {
41 pool.Get()
42 }
43 }()
44 }
45 wg.Wait()
46}

Callers

nothing calls this directly

Calls 7

NewOpenFilePoolFunction · 0.92
NewOpenFileFunction · 0.92
DoneMethod · 0.80
AddMethod · 0.65
PutMethod · 0.45
GetMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected