forked from External/ergo
remove registeredChannelsMutex
This moves channel registration to an eventual consistency model, where the in-memory datastructures (Channel and ChannelManager) are the exclusive source of truth, and updates to them get persisted asynchronously to the DB.
This commit is contained in:
parent
d5832bf765
commit
d4cb15354f
7 changed files with 318 additions and 247 deletions
|
|
@ -47,6 +47,12 @@ func (server *Server) DefaultChannelModes() Modes {
|
|||
return server.defaultChannelModes
|
||||
}
|
||||
|
||||
func (server *Server) ChannelRegistrationEnabled() bool {
|
||||
server.configurableStateMutex.RLock()
|
||||
defer server.configurableStateMutex.RUnlock()
|
||||
return server.channelRegistrationEnabled
|
||||
}
|
||||
|
||||
func (client *Client) Nick() string {
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
|
|
@ -95,6 +101,12 @@ func (client *Client) Destroyed() bool {
|
|||
return client.isDestroyed
|
||||
}
|
||||
|
||||
func (client *Client) AccountName() string {
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
return client.account.Name
|
||||
}
|
||||
|
||||
func (client *Client) HasMode(mode Mode) bool {
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
|
|
@ -174,6 +186,12 @@ func (channel *Channel) HasMode(mode Mode) bool {
|
|||
return channel.flags[mode]
|
||||
}
|
||||
|
||||
func (channel *Channel) Founder() string {
|
||||
channel.stateMutex.RLock()
|
||||
defer channel.stateMutex.RUnlock()
|
||||
return channel.registeredFounder
|
||||
}
|
||||
|
||||
// set a channel mode, return whether it was already set
|
||||
func (channel *Channel) setMode(mode Mode, enable bool) (already bool) {
|
||||
channel.stateMutex.Lock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue