Rename transitino tracer type and var
@@ -10,29 +10,29 @@ import (
"github.com/icon-project/goloop/common/log"
)
-type tracker struct {
+type tracer struct {
sync.Mutex
counter int32
liveTRIs []*transitionImpl
}
-var t tracker
+var trc tracer
-func (t *tracker) _liveTRIs() string {
+func (trc *tracer) _liveTRIs() string {
var buf bytes.Buffer
- for _, tri := range t.liveTRIs {
+ for _, tri := range trc.liveTRIs {
buf.WriteString(fmt.Sprintf(" %p(%d) ", tri, tri._nRef))
}
return buf.String()
}
func traceNewTransitionImpl(tri *transitionImpl) {
- t.Lock()
- defer t.Unlock()
+ trc.Lock()
+ defer trc.Unlock()
- t.counter++
- t.liveTRIs = append(t.liveTRIs, tri)
- log.Debugf("new TRI=%p nRef=%d counter=%d live:%s\n", tri, tri._nRef, t.counter, t._liveTRIs())
+ trc.counter++
+ trc.liveTRIs = append(trc.liveTRIs, tri)
+ log.Debugf("new TRI=%p nRef=%d counter=%d live:%s\n", tri, tri._nRef, trc.counter, trc._liveTRIs())
// log.Debugf("stack:%+v\n", errors.New("stack"))
}
@@ -42,22 +42,22 @@ func traceRef(tri *transitionImpl) {
}
func traceUnref(tri *transitionImpl) {
- t.Lock()
- defer t.Unlock()
+ trc.Lock()
+ defer trc.Unlock()
if tri._nRef != 0 {
log.Debugf("unref TRI=%p nRef=%d\n", tri, tri._nRef)
} else {
- t.counter--
- for i, ltri := range t.liveTRIs {
+ trc.counter--
+ for i, ltri := range trc.liveTRIs {
if ltri == tri {
- last := len(t.liveTRIs) - 1
- t.liveTRIs[i] = t.liveTRIs[last]
- t.liveTRIs[last] = nil
- t.liveTRIs = t.liveTRIs[:last]
+ last := len(trc.liveTRIs) - 1
+ trc.liveTRIs[i] = trc.liveTRIs[last]
+ trc.liveTRIs[last] = nil
+ trc.liveTRIs = trc.liveTRIs[:last]
}
}
- log.Debugf("unref TRI=%p nRef=%d counter=%d live:%s\n", tri, tri._nRef, t.counter, t._liveTRIs())
+ log.Debugf("unref TRI=%p nRef=%d counter=%d live:%s\n", tri, tri._nRef, trc.counter, trc._liveTRIs())
}
// log.Debugf("stack:%+v\n", errors.New("stack"))
}
