1
0
Fork 0
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:
Shivaram Lingamneni 2017-11-08 22:19:50 -05:00
parent d5832bf765
commit d4cb15354f
7 changed files with 318 additions and 247 deletions

View file

@ -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()