分支合并

This commit is contained in:
Hiven
2023-07-28 11:20:12 +08:00
18 changed files with 619 additions and 391 deletions

View File

@@ -0,0 +1,23 @@
package id_generator
import "sync"
type WebsocketId struct {
nodeId uint64
count uint64
mu sync.Mutex
}
func (wid *WebsocketId) Get() uint64 {
wid.mu.Lock()
defer wid.mu.Unlock()
wid.count++
return (wid.count << 8) | wid.nodeId
}
func NewWebsocketId(NodeId uint8) *WebsocketId {
return &WebsocketId{
nodeId: uint64(NodeId),
count: 0,
}
}