MCPcopy
hub / github.com/rclone/rclone / TestStringLock

Function TestStringLock

backend/sftp/stringlock_test.go:14–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestStringLock(t *testing.T) {
15 var wg sync.WaitGroup
16 counter := [3]int{}
17 lock := newStringLock()
18 const (
19 outer = 10
20 inner = 100
21 total = outer * inner
22 )
23 for range outer {
24 for j := range counter {
25 wg.Add(1)
26 go func(j int) {
27 defer wg.Done()
28 ID := fmt.Sprintf("%d", j)
29 for range inner {
30 lock.Lock(ID)
31 n := counter[j]
32 time.Sleep(1 * time.Millisecond)
33 counter[j] = n + 1
34 lock.Unlock(ID)
35 }
36
37 }(j)
38 }
39 }
40 wg.Wait()
41 assert.Equal(t, [3]int{total, total, total}, counter)
42}

Callers

nothing calls this directly

Calls 7

newStringLockFunction · 0.85
AddMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
WaitMethod · 0.65
DoneMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…