mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 19:57:48 +08:00
33 lines
476 B
Go
33 lines
476 B
Go
//----------------------------------------
|
|
//
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
//
|
|
// Licensed under GNU General Public License v3.0
|
|
//
|
|
//----------------------------------------
|
|
|
|
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
|
|
}
|