MCPcopy
hub / github.com/grpc/grpc-go / ExitIdleMode

Method ExitIdleMode

internal/idle/idle.go:212–240  ·  view source on GitHub ↗

ExitIdleMode instructs m to call the ClientConn's ExitIdleMode and update its internal state.

()

Source from the content-addressed store, hash-verified

210// ExitIdleMode instructs m to call the ClientConn's ExitIdleMode and update its
211// internal state.
212func (m *Manager) ExitIdleMode() {
213 // Holds idleMu which ensures mutual exclusion with tryEnterIdleMode.
214 m.idleMu.Lock()
215 defer m.idleMu.Unlock()
216
217 if m.isClosed() || !m.actuallyIdle {
218 // This can happen in three scenarios:
219 // - handleIdleTimeout() set the calls count to -math.MaxInt32 and called
220 // tryEnterIdleMode(). But before the latter could grab the lock, an RPC
221 // came in and OnCallBegin() noticed that the calls count is negative.
222 // - Channel is in idle mode, and multiple new RPCs come in at the same
223 // time, all of them notice a negative calls count in OnCallBegin and get
224 // here. The first one to get the lock would get the channel to exit idle.
225 // - Channel is not in idle mode, and the user calls Connect which calls
226 // m.ExitIdleMode.
227 //
228 // In any case, there is nothing to do here.
229 return
230 }
231
232 m.cc.ExitIdleMode()
233
234 // Undo the idle entry process. This also respects any new RPC attempts.
235 atomic.AddInt32(&m.activeCallsCount, math.MaxInt32)
236 m.actuallyIdle = false
237
238 // Start a new timer to fire after the configured idle timeout.
239 m.resetIdleTimerLocked(m.timeout)
240}
241
242// UnsafeSetNotIdle instructs the Manager to update its internal state to
243// reflect the reality that the channel is no longer in IDLE mode.

Calls 5

isClosedMethod · 0.95
resetIdleTimerLockedMethod · 0.95
ExitIdleModeMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45