24 lines
346 B
Go
24 lines
346 B
Go
package fusenrender
|
|
|
|
import "sync"
|
|
|
|
type UniqueId struct {
|
|
nodeId uint64
|
|
count uint64
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func (uid *UniqueId) Get() uint64 {
|
|
uid.mu.Lock()
|
|
defer uid.mu.Unlock()
|
|
uid.count++
|
|
return (uid.count << 8) | uid.nodeId
|
|
}
|
|
|
|
func NewUniqueIdd(NodeId uint8) *UniqueId {
|
|
return &UniqueId{
|
|
nodeId: uint64(NodeId),
|
|
count: 0,
|
|
}
|
|
}
|