1
This commit is contained in:
parent
28337e69ae
commit
fe8befa333
@ -153,17 +153,24 @@ func (this* guildMgr) removeUsingName(name string) {
|
||||
delete(this.usingNameHash, name)
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string,
|
||||
func (this* guildMgr) genMemberLockKey(accountId string) string {
|
||||
return accountId
|
||||
}
|
||||
|
||||
func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string, avatar int32, name string,
|
||||
cb func(int32, string, int64)) {
|
||||
if this.internalGetGuildByAccountId(accountId) != nil {
|
||||
task.SetFail()
|
||||
cb(1, "", 0)
|
||||
return
|
||||
}
|
||||
if this.internalGetGuildByGuildName(name) != nil {
|
||||
task.SetFail()
|
||||
cb(1, "", 0)
|
||||
return
|
||||
}
|
||||
if this.isUsingName(name) {
|
||||
task.SetFail()
|
||||
cb(1, "", 0)
|
||||
return
|
||||
}
|
||||
@ -185,6 +192,7 @@ func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name stri
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
this.removeUsingName(name)
|
||||
if err != nil {
|
||||
task.SetFail()
|
||||
cb(1, "", 0)
|
||||
return
|
||||
}
|
||||
@ -208,26 +216,38 @@ func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name stri
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
task.SetFail()
|
||||
cb(1, "", 0)
|
||||
return
|
||||
}
|
||||
guild := newGuild()
|
||||
this.idHash[guild.guildId] = guild
|
||||
this.nameHash[guild.guildName] = guild
|
||||
//this.accountIdHash[accountId] = guild
|
||||
oldGuild := this.internalGetGuildByAccountId(accountId)
|
||||
if oldGuild != nil {
|
||||
|
||||
task.SetFail()
|
||||
panic(fmt.Sprintf("asyncCreateGuildTask:%s", ""))
|
||||
} else {
|
||||
m := newMember()
|
||||
m.init(guild, accountId, q5.ToInt32(nowTime))
|
||||
guild.addMember(m)
|
||||
//this.accountIdHash[accountId] = guild
|
||||
this.memberIdHash[accountId] = m
|
||||
task.SetSucc()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string,
|
||||
cb func(int32, string, int64)) {
|
||||
lockKey := this.genMemberLockKey(accountId)
|
||||
f5.GetApp().AsyncLock(lockKey,
|
||||
f5.NewAsyncTask(
|
||||
func (task *f5.AsyncTask) {
|
||||
this.asyncCreateGuildTask(task, accountId, avatar, name, cb)
|
||||
}))
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncGetApplyList(lastIdx int64, accountId string,
|
||||
cb func(int32, string, int64, []string)) {
|
||||
guild := this.GetGuildByAccountId(accountId)
|
||||
|
@ -7,7 +7,6 @@ type member struct {
|
||||
guild *guild
|
||||
memberId string
|
||||
joinTime int32
|
||||
wLock int32
|
||||
}
|
||||
|
||||
func (this *member) init(guild *guild, memberId string, joinTime int32) {
|
||||
@ -16,14 +15,6 @@ func (this *member) init(guild *guild, memberId string, joinTime int32) {
|
||||
this.joinTime = joinTime
|
||||
}
|
||||
|
||||
func (this *member) lock() {
|
||||
this.wLock++
|
||||
}
|
||||
|
||||
func (this *member) unlock() {
|
||||
this.wLock--
|
||||
}
|
||||
|
||||
func newMember() *member {
|
||||
p := new(member)
|
||||
return p
|
||||
|
2
third_party/f5
vendored
2
third_party/f5
vendored
@ -1 +1 @@
|
||||
Subproject commit 1a19949e6464872e9d54154bc69e13cfc858d106
|
||||
Subproject commit 178d811f9a45f33616901861e95f82e1d055bc83
|
Loading…
x
Reference in New Issue
Block a user