De-race types.RoomInfo (#2600)

This commit is contained in:
Neil Alexander 2022-08-01 15:29:19 +01:00 committed by GitHub
parent 05c83923e3
commit 119cde3766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 72 additions and 42 deletions

View file

@ -19,6 +19,7 @@ import (
"encoding/json"
"sort"
"strings"
"sync"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@ -279,8 +280,33 @@ func (e RejectedError) Error() string { return string(e) }
// RoomInfo contains metadata about a room
type RoomInfo struct {
mu sync.RWMutex
RoomNID RoomNID
RoomVersion gomatrixserverlib.RoomVersion
StateSnapshotNID StateSnapshotNID
IsStub bool
stateSnapshotNID StateSnapshotNID
isStub bool
}
func (r *RoomInfo) StateSnapshotNID() StateSnapshotNID {
r.mu.RLock()
defer r.mu.RUnlock()
return r.stateSnapshotNID
}
func (r *RoomInfo) IsStub() bool {
r.mu.RLock()
defer r.mu.RUnlock()
return r.isStub
}
func (r *RoomInfo) SetStateSnapshotNID(nid StateSnapshotNID) {
r.mu.Lock()
defer r.mu.Unlock()
r.stateSnapshotNID = nid
}
func (r *RoomInfo) SetIsStub(isStub bool) {
r.mu.Lock()
defer r.mu.Unlock()
r.isStub = isStub
}