MCPcopy
hub / github.com/redis/go-redis / SetUsed

Method SetUsed

internal/pool/conn.go:368–374  ·  view source on GitHub ↗

SetUsed sets the used flag for the connection (lock-free). This should be called when returning a connection to the pool (set to false) or when a single-connection pool retrieves its connection (set to true). Prefer CompareAndSwapUsed() when acquiring from a multi-connection pool to avoid race con

(val bool)

Source from the content-addressed store, hash-verified

366// avoid race conditions.
367// Deprecated: Use GetStateMachine().Transition() directly for better state management.
368func (cn *Conn) SetUsed(val bool) {
369 if val {
370 cn.stateMachine.Transition(StateInUse)
371 } else {
372 cn.stateMachine.Transition(StateIdle)
373 }
374}
375
376// getNetConn returns the current network connection using atomic load (lock-free).
377// This is the fast path for accessing netConn without mutex overhead.

Callers 5

createMockPoolConnectionFunction · 0.95
TestConn_UsedMethodsFunction · 0.95
GetMethod · 0.80
PutMethod · 0.80
RemoveMethod · 0.80

Calls 1

TransitionMethod · 0.80

Tested by 2

createMockPoolConnectionFunction · 0.76
TestConn_UsedMethodsFunction · 0.76