Skip to content

Commit

Permalink
Flat container storage abstraction
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru committed Jul 8, 2024
1 parent 59a9aea commit 3f9d387
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion container/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ license = "MIT"

[dependencies]
columnation = { git = "https://github.com/frankmcsherry/columnation" }
flatcontainer = "0.5"
# flatcontainer = "0.5"
flatcontainer = { git = "https://github.com/antiguru/flatcontainer" }
serde = { version = "1.0"}
14 changes: 12 additions & 2 deletions container/src/flatcontainer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
//! Present a [`FlatStack`] as a timely container.

pub use flatcontainer::*;
use flatcontainer::impls::index::IndexContainer;
use crate::{buffer, Container, SizableContainer, PushInto};

impl<R: Region + Clone + 'static> Container for FlatStack<R> {
impl<R, S> Container for FlatStack<R, S>
where
R: Region + Clone + 'static,
S: IndexContainer<<R as Region>::Index> + Clone + 'static,
{
type ItemRef<'a> = R::ReadItem<'a> where Self: 'a;
type Item<'a> = R::ReadItem<'a> where Self: 'a;

Expand All @@ -28,6 +33,7 @@ impl<R: Region + Clone + 'static> Container for FlatStack<R> {
}
}

// Only implemented for `FlatStack` with `Vec` offsets.
impl<R: Region + Clone + 'static> SizableContainer for FlatStack<R> {
fn capacity(&self) -> usize {
self.capacity()
Expand All @@ -42,7 +48,11 @@ impl<R: Region + Clone + 'static> SizableContainer for FlatStack<R> {
}
}

impl<R: Region + Push<T>, T> PushInto<T> for FlatStack<R> {
impl<R, S, T> PushInto<T> for FlatStack<R, S>
where
R: Region + Push<T>,
S: IndexContainer<R::Index> + Clone + 'static,
{
#[inline]
fn push_into(&mut self, item: T) {
self.copy(item);
Expand Down
12 changes: 12 additions & 0 deletions timely/src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ mod product {
}
}

impl<'a, 'b, RO, RI> ReserveItems<&'b Product<RO::ReadItem<'a>, RI::ReadItem<'a>>> for ProductRegion<RO, RI>
where
RO: Region + ReserveItems<&'b <RO as Region>::ReadItem<'a>> + 'a,
RI: Region + ReserveItems<&'b <RI as Region>::ReadItem<'a>> + 'a,
{
#[inline]
fn reserve_items<I>(&mut self, items: I) where I: Iterator<Item=&'b Product<RO::ReadItem<'a>, RI::ReadItem<'a>>> + Clone {
self.outer_region.reserve_items(items.clone().map(|i| &i.outer));
self.inner_region.reserve_items(items.clone().map(|i| &i.inner));
}
}

impl<TO, TI, RO, RI> Push<Product<TO, TI>> for ProductRegion<RO, RI>
where
RO: Region + Push<TO>,
Expand Down

0 comments on commit 3f9d387

Please sign in to comment.