getNetConn returns the current network connection using atomic load (lock-free). This is the fast path for accessing netConn without mutex overhead.
()
| 376 | // getNetConn returns the current network connection using atomic load (lock-free). |
| 377 | // This is the fast path for accessing netConn without mutex overhead. |
| 378 | func (cn *Conn) getNetConn() net.Conn { |
| 379 | if v := cn.netConnAtomic.Load(); v != nil { |
| 380 | if wrapper, ok := v.(*atomicNetConn); ok { |
| 381 | return wrapper.conn |
| 382 | } |
| 383 | } |
| 384 | return nil |
| 385 | } |
| 386 | |
| 387 | // setNetConn stores the network connection atomically (lock-free). |
| 388 | // This is used for the fast path of connection replacement. |