Skip to content

Commit

Permalink
temp!
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Nov 20, 2024
1 parent c6246f7 commit 2e77be2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/matrix-sdk-base/src/event_cache/store/memory_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ use std::{collections::HashMap, num::NonZeroUsize, sync::RwLock as StdRwLock, ti

use async_trait::async_trait;
use matrix_sdk_common::{
linked_chunk::Update, ring_buffer::RingBuffer,
store_locks::memory_store_helper::try_take_leased_lock,
linked_chunk::{LinkedChunk, Update},
ring_buffer::RingBuffer,
store_locks::memory_store_helper::{handle_linked_chunk_updates, try_take_leased_lock},
};
use ruma::{MxcUri, OwnedMxcUri};

use super::{EventCacheStore, EventCacheStoreError, Result};
use crate::{
event_cache::{Event, Gap},
event_cache::{Event, Gap, DEFAULT_CHUNK_CAPACITY},
media::{MediaRequestParameters, UniqueKey as _},
};

Expand All @@ -35,6 +36,7 @@ use crate::{
pub struct MemoryStore {
media: StdRwLock<RingBuffer<(OwnedMxcUri, String /* unique key */, Vec<u8>)>>,
leases: StdRwLock<HashMap<String, (String, Instant)>>,
events: StdRwLock<LinkedChunk<DEFAULT_CHUNK_CAPACITY, Event, Gap>>,
}

// SAFETY: `new_unchecked` is safe because 20 is not zero.
Expand All @@ -45,6 +47,7 @@ impl Default for MemoryStore {
Self {
media: StdRwLock::new(RingBuffer::new(NUMBER_OF_MEDIAS)),
leases: Default::default(),
events: StdRwLock::new(LinkedChunk::new()),
}
}
}
Expand Down Expand Up @@ -74,7 +77,7 @@ impl EventCacheStore for MemoryStore {
&self,
updates: &[Update<Event, Gap>],
) -> Result<(), Self::Error> {
todo!()
Ok(handle_linked_chunk_updates(&self.events, updates))
}

async fn add_media_content(
Expand Down
12 changes: 12 additions & 0 deletions crates/matrix-sdk-common/src/store_locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,16 @@ pub mod memory_store_helper {
}
}
}

pub fn handle_linked_chunk_updates<const CHUNK_CAPACITY: usize, Event, Gap>(
linked_chunk: &RwLock<LinkedChunk<CHUNK_CAPACITY, Event, Gap>>,
updates: &[Update<Event, Gap>],
) {
for update in updates {
match update {
Update::NewItemsChunk
}
}
todo!()
}
}

0 comments on commit 2e77be2

Please sign in to comment.