1
2
3
4
5
12 package main
13
14 import (
15 "os"
16 "runtime"
17 "runtime/pprof"
18 "sync"
19 "time"
20 )
21
22 func init() {
23 register("Kubernetes10182", Kubernetes10182)
24 }
25
26 type statusManager_kubernetes10182 struct {
27 podStatusesLock sync.RWMutex
28 podStatusChannel chan bool
29 }
30
31 func (s *statusManager_kubernetes10182) Start() {
32 go func() {
33 for i := 0; i < 2; i++ {
34 s.syncBatch()
35 }
36 }()
37 }
38
39 func (s *statusManager_kubernetes10182) syncBatch() {
40 runtime.Gosched()
41 <-s.podStatusChannel
42 s.DeletePodStatus()
43 }
44
45 func (s *statusManager_kubernetes10182) DeletePodStatus() {
46 s.podStatusesLock.Lock()
47 defer s.podStatusesLock.Unlock()
48 }
49
50 func (s *statusManager_kubernetes10182) SetPodStatus() {
51 s.podStatusesLock.Lock()
52 defer s.podStatusesLock.Unlock()
53 s.podStatusChannel <- true
54 }
55
56 func NewStatusManager_kubernetes10182() *statusManager_kubernetes10182 {
57 return &statusManager_kubernetes10182{
58 podStatusChannel: make(chan bool),
59 }
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 func Kubernetes10182() {
81 prof := pprof.Lookup("goroutineleak")
82 defer func() {
83 time.Sleep(100 * time.Millisecond)
84 prof.WriteTo(os.Stdout, 2)
85 }()
86
87 for i := 0; i < 1000; i++ {
88 go func() {
89 s := NewStatusManager_kubernetes10182()
90 go s.Start()
91 go s.SetPodStatus()
92 go s.SetPodStatus()
93 }()
94 }
95 }
96
View as plain text