mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 01:13:10 -06:00
Update comments
This commit is contained in:
parent
5d6169632a
commit
11251c9762
|
|
@ -106,9 +106,8 @@ func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, userID string, pos ty
|
|||
}
|
||||
}
|
||||
|
||||
// WaitForEvents blocks until there are events for this request after sincePos.
|
||||
// In particular, it will return immediately if there are already events after
|
||||
// sincePos for the request, but otherwise blocks waiting for new events.
|
||||
// WaitForEvents returns a channel that produces a single stream position when
|
||||
// a new event *may* be available to return to the client.
|
||||
func (n *Notifier) WaitForEvents(req syncRequest, sincePos types.StreamPosition) <-chan types.StreamPosition {
|
||||
// Do what synapse does: https://github.com/matrix-org/synapse/blob/v0.20.0/synapse/notifier.py#L298
|
||||
// - Bucket request into a lookup map keyed off a list of joined room IDs and separately a user ID
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ func NewUserStream(userID string, currPos types.StreamPosition) *UserStream {
|
|||
}
|
||||
}
|
||||
|
||||
// Wait blocks until there is a new stream position for this user, which is then returned.
|
||||
// waitAtPos should be the position the stream thinks it should be waiting at.
|
||||
// Wait returns a channel that produces a single stream position when
|
||||
// a new event *may* be available to return to the client.
|
||||
func (s *UserStream) Wait(ctx context.Context, waitAtPos types.StreamPosition) <-chan types.StreamPosition {
|
||||
posChannel := make(chan types.StreamPosition, 1)
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ func (s *UserStream) Wait(ctx context.Context, waitAtPos types.StreamPosition) <
|
|||
if posChannel == ch {
|
||||
lastIdx := len(s.waitingChannels)
|
||||
s.waitingChannels[idx] = s.waitingChannels[lastIdx]
|
||||
s.waitingChannels[lastIdx] = nil
|
||||
s.waitingChannels[lastIdx] = nil // Ensure that the channel gets GCed
|
||||
s.waitingChannels = s.waitingChannels[:lastIdx]
|
||||
|
||||
if len(s.waitingChannels) == 0 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue