energy/common/ids.go
杨红岩 03e3f74c7f 1. commons -> common
2. 增加内置资源http服务
2022-11-02 12:47:47 +08:00

25 lines
285 B
Go

package common
import "sync"
// IPC ID生成
type IPCIDGen struct {
_id int32
mutex sync.Mutex
}
type CliID struct {
IPCIDGen
}
// 消息ID生成
type MsgID struct {
IPCIDGen
}
func (m *IPCIDGen) New() int32 {
m.mutex.Lock()
defer m.mutex.Unlock()
m._id++
return m._id
}