aboutsummaryrefslogtreecommitdiff
path: root/matrix/rooms
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-23 14:44:36 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-23 14:44:36 +0200
commit03e9a0d5ac5329a6e74f3e3bf34ef590c863a6d3 (patch)
treede6c068cf050ba331761a9b61819dfc89e18391e /matrix/rooms
parent7cc55ade3060ee71c4ae38462a27bf92d6c2c932 (diff)
Documentation and refactoring
Diffstat (limited to 'matrix/rooms')
-rw-r--r--matrix/rooms/member.go1
-rw-r--r--matrix/rooms/room.go13
2 files changed, 11 insertions, 3 deletions
diff --git a/matrix/rooms/member.go b/matrix/rooms/member.go
index 20c994b..8fd84e9 100644
--- a/matrix/rooms/member.go
+++ b/matrix/rooms/member.go
@@ -20,6 +20,7 @@ import (
"maunium.net/go/gomatrix"
)
+// Membership is an enum specifying the membership state of a room member.
type Membership string
// The allowed membership states as specified in spec section 10.5.5.
diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go
index 56614de..c24b6db 100644
--- a/matrix/rooms/room.go
+++ b/matrix/rooms/room.go
@@ -34,17 +34,22 @@ type Room struct {
SessionUserID string
// MXID -> Member cache calculated from membership events.
memberCache map[string]*Member
- // The first non-SessionUserID member in the room. Calculated at the same time as memberCache.
+ // The first non-SessionUserID member in the room. Calculated at
+ // the same time as memberCache.
firstMemberCache string
- // The name of the room. Calculated from the state event name, canonical_alias or alias or the member cache.
+ // The name of the room. Calculated from the state event name,
+ // canonical_alias or alias or the member cache.
nameCache string
// The topic of the room. Directly fetched from the m.room.topic state event.
topicCache string
- // fetchHistoryLock is used to make sure multiple goroutines don't fetch history for this room at the same time.
+ // fetchHistoryLock is used to make sure multiple goroutines don't fetch
+ // history for this room at the same time.
fetchHistoryLock *sync.Mutex
}
+// LockHistory locks the history fetching mutex.
+// If the mutex is nil, it will be created.
func (room *Room) LockHistory() {
if room.fetchHistoryLock == nil {
room.fetchHistoryLock = &sync.Mutex{}
@@ -52,6 +57,8 @@ func (room *Room) LockHistory() {
room.fetchHistoryLock.Lock()
}
+// UnlockHistory unlocks the history fetching mutex.
+// If the mutex is nil, this does nothing.
func (room *Room) UnlockHistory() {
if room.fetchHistoryLock != nil {
room.fetchHistoryLock.Unlock()