Skip to content
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88f67e4
chore(common) Rename `CrossProcessLockKind` to `CrossProcessLockState`.
Hywan Nov 11, 2025
14aad28
feat(common) Add `#[must_use]` on `CrossProcessLockGuard` and `*State`.
Hywan Nov 11, 2025
6a2af4a
feat(common): Add `CrossProcessLockState::map`.
Hywan Nov 11, 2025
9c46b96
feat(base) Create the `EventCacheStoreLockState` type.
Hywan Nov 11, 2025
7ea191d
chore(sdk): Clean up imports.
Hywan Nov 11, 2025
32f136b
feat(common): Add `CrossProcessLockGuard::is_dirty` and `::clear_dirty`.
Hywan Nov 11, 2025
f5710f4
feat(base): Add `EventCacheStoreLockGuard::clear_dirty`.
Hywan Nov 11, 2025
87fa020
refactor(base): `EventCacheStoreLockState` owns a clone of the inner …
Hywan Nov 11, 2025
a48edd2
feat(common): `CrossProcessLockGuard` can be cloned.
Hywan Nov 12, 2025
ea3798a
feat(base): `EventCacheStoreLockGuard` can be cloned.
Hywan Nov 12, 2025
07b095d
fix(base): Use the `EventCacheStoreLockState`.
Hywan Nov 11, 2025
8b612cc
test(sdk): Update to use `EventCacheStoreLockState`.
Hywan Nov 11, 2025
56706ac
refactor(sdk) Introduce `RoomEventCacheStateLock` and read/write guards.
Hywan Nov 12, 2025
046e05f
feat(sdk): Reset `RoomEventCacheState` when the cross-process lock is…
Hywan Nov 18, 2025
3c4afc1
doc(sdk): Add missing or fix documentation.
Hywan Nov 18, 2025
f288e5f
fix(sdk): Remove a warning for `wasm32`.
Hywan Nov 18, 2025
8ee41f4
test(common): Test dirtiness of the cross-process lock.
Hywan Nov 18, 2025
ebbd1fe
test(common): Make tests run faster.
Hywan Nov 19, 2025
900f084
feat(sdk): Implement `RoomEventCacheStateLockWriteGuard::downgrade`.
Hywan Nov 19, 2025
6163013
feat(sdk): Allow shared access on `RoomEventCacheStateLock::read`.
Hywan Nov 19, 2025
cf881ab
test(sdk): Add the `test_reset_when_dirty` test.
Hywan Nov 19, 2025
7a163c1
refactor(sdk): Rename `RoomEventCacheInner::sender` to `update_sender`.
Hywan Nov 21, 2025
a32724b
feat(sdk): Send updates when `RoomEventCacheStateLock` is reloaded.
Hywan Nov 21, 2025
a6eae60
test(sdk): Ensure `EventCacheStoreLockGuard::clear_dirty` is called!
Hywan Nov 21, 2025
82fd99d
test(sdk): Add a test for dirtiness handling in `RoomEventCacheStateL…
Hywan Nov 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions crates/matrix-sdk/src/event_cache/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,6 @@ mod private {
match state_guard.store.lock().await? {
EventCacheStoreLockState::Clean(store_guard) => {
Ok(RoomEventCacheStateLockReadGuard {
// Downgrade to a read-lock.
state: state_guard.downgrade(),
store: store_guard,
})
Expand All @@ -845,11 +844,7 @@ mod private {
// All good now, mark the cross-process lock as non-dirty.
EventCacheStoreLockGuard::clear_dirty(&guard.store);

Ok(RoomEventCacheStateLockReadGuard {
// Downgrade to a read-lock.
state: guard.state.downgrade(),
store: guard.store,
})
Ok(guard.downgrade())
}
}
}
Expand Down Expand Up @@ -909,6 +904,19 @@ mod private {
store: EventCacheStoreLockGuard,
}

impl<'a> RoomEventCacheStateLockWriteGuard<'a> {
/// Synchronously downgrades a write lock into a read lock.
///
/// The per-thread/state lock is downgraded atomically, without allowing
/// any writers to take exclusive access of the lock in the meantime.
///
/// It returns an RAII guard which will drop the write access to the
/// state and to the store when dropped.
fn downgrade(self) -> RoomEventCacheStateLockReadGuard<'a> {
RoomEventCacheStateLockReadGuard { state: self.state.downgrade(), store: self.store }
}
}

impl<'a> RoomEventCacheStateLockReadGuard<'a> {
/// Returns a read-only reference to the underlying room linked chunk.
pub fn room_linked_chunk(&self) -> &EventLinkedChunk {
Expand Down