Skip to content

Commit

Permalink
add atomic.Uint64 instead of atomic operation
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Apr 26, 2023
1 parent 75fc625 commit 9294ad2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smallnest/rpcx

go 1.19
go 1.20

require (
github.com/ChimeraCoder/gojson v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Server struct {
mu sync.RWMutex
activeConn map[net.Conn]struct{}
doneChan chan struct{}
seq uint64
seq atomic.Uint64

inShutdown int32
onShutdown []func(s *Server)
Expand Down Expand Up @@ -185,7 +185,7 @@ func (s *Server) SendMessage(conn net.Conn, servicePath, serviceMethod string, m
req := protocol.NewMessage()
req.SetMessageType(protocol.Request)

seq := atomic.AddUint64(&s.seq, 1)
seq := s.seq.Add(1)
req.SetSeq(seq)
req.SetOneway(true)
req.SetSerializeType(protocol.SerializeNone)
Expand Down

0 comments on commit 9294ad2

Please sign in to comment.