Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flat container storage abstraction #574

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for flatcontainer 0.6

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
Loading