SetUsable sets the usable flag for the connection (lock-free). Deprecated: Use GetStateMachine().Transition() directly for better state management. This method is kept for backwards compatibility. This should be called to mark a connection as usable after initialization or to release it after a ba
(usable bool)
| 295 | // Prefer CompareAndSwapUsable() when acquiring exclusive access to avoid race conditions. |
| 296 | // Deprecated: Use GetStateMachine().Transition() directly for better state management. |
| 297 | func (cn *Conn) SetUsable(usable bool) { |
| 298 | if usable { |
| 299 | // Transition to IDLE state (ready to be acquired) |
| 300 | cn.stateMachine.Transition(StateIdle) |
| 301 | } else { |
| 302 | // Transition to UNUSABLE state (for background operations) |
| 303 | cn.stateMachine.Transition(StateUnusable) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // IsInited returns true if the connection has been initialized. |
| 308 | // This is a backward-compatible wrapper around the state machine. |