MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / loop

Method loop

sdk/cliproxy/auth/auto_refresh_loop.go:122–150  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

120}
121
122func (l *authAutoRefreshLoop) loop(ctx context.Context) {
123 timer := time.NewTimer(time.Hour)
124 if !timer.Stop() {
125 select {
126 case <-timer.C:
127 default:
128 }
129 }
130 defer timer.Stop()
131
132 var timerCh <-chan time.Time
133 l.resetTimer(timer, &timerCh, time.Now())
134
135 for {
136 select {
137 case <-ctx.Done():
138 return
139 case <-l.wakeCh:
140 now := time.Now()
141 l.applyDirty(now)
142 l.resetTimer(timer, &timerCh, now)
143 case <-timerCh:
144 now := time.Now()
145 l.handleDue(ctx, now)
146 l.applyDirty(now)
147 l.resetTimer(timer, &timerCh, now)
148 }
149 }
150}
151
152func (l *authAutoRefreshLoop) resetTimer(timer *time.Timer, timerCh *<-chan time.Time, now time.Time) {
153 next, ok := l.peek()

Callers 1

runMethod · 0.95

Calls 4

resetTimerMethod · 0.95
applyDirtyMethod · 0.95
handleDueMethod · 0.95
StopMethod · 0.65

Tested by

no test coverage detected