File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ type bundle struct {
4949 wsUpgrade websocket.FastHTTPUpgrader
5050 wsRoutes map [string ]* routeData
5151 wsEndpoint string
52- wsNextID uint64
52+ wsNextID atomic. Uint64
5353 predicateKey string
5454 rpcInFactory kit.IncomingRPCFactory
5555 rpcOutFactory kit.OutgoingRPCFactory
@@ -244,7 +244,7 @@ func (b *bundle) wsHandler(ctx *fasthttp.RequestCtx) {
244244 func (conn * websocket.Conn ) {
245245 wsc := & wsConn {
246246 kv : map [string ]string {},
247- id : atomic . AddUint64 ( & b .wsNextID , 1 ),
247+ id : b .wsNextID . Add ( 1 ),
248248 clientIP : realip .FromRequest (ctx ),
249249 c : conn ,
250250 rpcOutFactory : b .rpcOutFactory ,
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ type gateway struct {
1717 utils.SpinLock
1818
1919 b * bundle
20- nextID uint64
20+ nextID atomic. Uint64
2121 conns map [uint64 ]* wsConn
2222}
2323
@@ -51,7 +51,7 @@ func (gw *gateway) OnShutdown(_ gnet.Engine) {}
5151
5252func (gw * gateway ) OnOpen (c gnet.Conn ) (out []byte , action gnet.Action ) {
5353 wsc := newWebsocketConn (
54- atomic . AddUint64 ( & gw .nextID , 1 ),
54+ gw .nextID . Add ( 1 ),
5555 c ,
5656 gw .b .rpcOutFactory ,
5757 gw .b .writeMode ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ type WebsocketCtx struct {
3131
3232 pendingMtx sync.Mutex
3333 pending map [string ]chan kit.IncomingRPCContainer
34- lastActivity uint32
34+ lastActivity atomic. Uint32
3535 disconnectChan chan struct {}
3636
3737 // fasthttp entities
@@ -116,11 +116,11 @@ func (wCtx *WebsocketCtx) Reconnect(ctx context.Context) error {
116116}
117117
118118func (wCtx * WebsocketCtx ) setActivity () {
119- atomic . StoreUint32 ( & wCtx .lastActivity , uint32 (utils .TimeUnix ()))
119+ wCtx .lastActivity . Store ( uint32 (utils .TimeUnix ()))
120120}
121121
122122func (wCtx * WebsocketCtx ) getActivity () int64 {
123- return int64 (atomic . LoadUint32 ( & wCtx .lastActivity ))
123+ return int64 (wCtx .lastActivity . Load ( ))
124124}
125125
126126func (wCtx * WebsocketCtx ) watchdog (c * websocket.Conn ) {
You can’t perform that action at this time.
0 commit comments