41 lines
687 B
Plaintext
41 lines
687 B
Plaintext
package sqlAsyncMgr
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// 标识内容模型对象
|
|
type StatisticModel struct {
|
|
// 锁对象
|
|
m sync.Mutex
|
|
|
|
// 标识
|
|
IdentityId string
|
|
|
|
// 待同步的数量
|
|
Count int32
|
|
}
|
|
|
|
// AddCount 添加指定数量
|
|
func (this *StatisticModel) AddCount(addcount int32) {
|
|
this.m.Lock()
|
|
defer this.m.Unlock()
|
|
|
|
this.Count = this.Count + addcount
|
|
}
|
|
|
|
// ReduceCount 添加指定数量
|
|
func (this *StatisticModel) ReduceCount(recount int32) {
|
|
this.m.Lock()
|
|
defer this.m.Unlock()
|
|
|
|
this.Count = this.Count - recount
|
|
}
|
|
|
|
// newStatisticModel 创建新StatisticModel对象
|
|
func newStatisticModel(ident string) *StatisticModel {
|
|
return &StatisticModel{
|
|
IdentityId: ident,
|
|
}
|
|
}
|