1
2
3
4
5
12 package main
13
14 import (
15 "os"
16 "runtime/pprof"
17 "sync"
18 "time"
19 )
20
21 func init() {
22 register("Kubernetes6632", Kubernetes6632)
23 }
24
25 type Connection_kubernetes6632 struct {
26 closeChan chan bool
27 }
28
29 type idleAwareFramer_kubernetes6632 struct {
30 resetChan chan bool
31 writeLock sync.Mutex
32 conn *Connection_kubernetes6632
33 }
34
35 func (i *idleAwareFramer_kubernetes6632) monitor() {
36 var resetChan = i.resetChan
37 Loop:
38 for {
39 select {
40 case <-i.conn.closeChan:
41 i.writeLock.Lock()
42 close(resetChan)
43 i.resetChan = nil
44 i.writeLock.Unlock()
45 break Loop
46 }
47 }
48 }
49
50 func (i *idleAwareFramer_kubernetes6632) WriteFrame() {
51 i.writeLock.Lock()
52 defer i.writeLock.Unlock()
53 if i.resetChan == nil {
54 return
55 }
56 i.resetChan <- true
57 }
58
59 func NewIdleAwareFramer_kubernetes6632() *idleAwareFramer_kubernetes6632 {
60 return &idleAwareFramer_kubernetes6632{
61 resetChan: make(chan bool),
62 conn: &Connection_kubernetes6632{
63 closeChan: make(chan bool),
64 },
65 }
66 }
67
68 func Kubernetes6632() {
69 prof := pprof.Lookup("goroutineleak")
70 defer func() {
71 time.Sleep(100 * time.Millisecond)
72 prof.WriteTo(os.Stdout, 2)
73 }()
74
75 for i := 0; i < 100; i++ {
76 go func() {
77 i := NewIdleAwareFramer_kubernetes6632()
78
79 go func() {
80 i.conn.closeChan <- true
81 }()
82 go i.monitor()
83 go i.WriteFrame()
84 }()
85 }
86 }
87
View as plain text