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)
| 366 | // avoid race conditions. |
| 367 | // Deprecated: Use GetStateMachine().Transition() directly for better state management. |
| 368 | func (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. |