/
Undeadguy
/
dendrite
Обзор
Документация
Войти
/
Undeadguy
/
dendrite
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
syncapi/streams/template_stream.go
40 строк
729 B
Neil Alexander
Transactional isolation for `/sync` (#2745)
30 сен 2022, 14:48
Не верифицирован
30 сен 2022, 14:48
6348486
Код
Авторство
О чём код?
package streams import ( "context" "sync" "github.com/matrix-org/dendrite/syncapi/storage" "github.com/matrix-org/dendrite/syncapi/types" ) type DefaultStreamProvider struct { DB storage.Database latest types.StreamPosition latestMutex sync.RWMutex } func (p *DefaultStreamProvider) Setup( ctx context.Context, snapshot storage.DatabaseTransaction, ) { } func (p *DefaultStreamProvider) Advance( latest types.StreamPosition, ) { p.latestMutex.Lock() defer p.latestMutex.Unlock() if latest > p.latest { p.latest = latest } } func (p *DefaultStreamProvider) LatestPosition( ctx context.Context, ) types.StreamPosition { p.latestMutex.RLock() defer p.latestMutex.RUnlock() return p.latest }