44
55use std:: collections:: VecDeque ;
66
7- /// A container transferring data through dataflow edges
7+ /// An object with effects on progress
88///
9- /// A container stores a number of updates and thus is able to describe it count
9+ /// The object stores a number of updates and thus is able to describe it count
1010/// (`update_count()`) and whether it is empty (`is_empty()`). It is empty if the
1111/// update count is zero.
1212///
13- /// A container must implement default. The default implementation is not required to allocate
14- /// memory for variable-length components.
13+ /// It must implement default for historic reason. The default implementation is not required
14+ /// to allocate memory for variable-length components.
15+ // TODO: Remove `Default` requirement in the future.
1516// The container is `Default` because `CapacityContainerBuilder` only implements `ContainerBuilder`
1617// for containers that implement `Default`, and we use the associated `::Container` all over Timely.
1718// We can only access the type if all requirements for the `ContainerBuilder` implementation are
1819// satisfied.
19- pub trait Container : Default {
20- /// The number of updates in this container
20+ pub trait WithProgress : Default {
21+ /// The number of updates
2122 ///
2223 /// This number is used in progress tracking to confirm the receipt of some number
2324 /// of outstanding updates, and it is highly load bearing. The main restriction is
2425 /// imposed on the `LengthPreservingContainerBuilder` trait, whose implementors
2526 /// must preserve the number of items.
2627 fn update_count ( & self ) -> i64 ;
2728
28- /// Determine if the container contains any updates, corresponding to `update_count() == 0`.
29+ /// Determine if this contains any updates, corresponding to `update_count() == 0`.
2930 #[ inline] fn is_empty ( & self ) -> bool { self . update_count ( ) == 0 }
3031}
3132
@@ -51,7 +52,7 @@ pub trait DrainContainer {
5152}
5253
5354/// A container that can be sized and reveals its capacity.
54- pub trait SizableContainer : Container {
55+ pub trait SizableContainer : WithProgress {
5556 /// Indicates that the container is "full" and should be shipped.
5657 fn at_capacity ( & self ) -> bool ;
5758 /// Restores `self` to its desired capacity, if it has one.
@@ -95,7 +96,7 @@ pub trait ContainerBuilder: Default + 'static {
9596 /// The container type we're building.
9697 // The container is `Clone` because `Tee` requires it, otherwise we need to repeat it
9798 // all over Timely. `'static` because we don't want lifetimes everywhere.
98- type Container : Container + Clone + ' static ;
99+ type Container : WithProgress + Clone + ' static ;
99100 /// Extract assembled containers, potentially leaving unfinished data behind. Can
100101 /// be called repeatedly, for example while the caller can send data.
101102 ///
@@ -167,7 +168,7 @@ impl<T, C: SizableContainer + PushInto<T>> PushInto<T> for CapacityContainerBuil
167168 }
168169}
169170
170- impl < C : Container + Clone + ' static > ContainerBuilder for CapacityContainerBuilder < C > {
171+ impl < C : WithProgress + Clone + ' static > ContainerBuilder for CapacityContainerBuilder < C > {
171172 type Container = C ;
172173
173174 #[ inline]
@@ -190,9 +191,9 @@ impl<C: Container + Clone + 'static> ContainerBuilder for CapacityContainerBuild
190191 }
191192}
192193
193- impl < C : Container + Clone + ' static > LengthPreservingContainerBuilder for CapacityContainerBuilder < C > { }
194+ impl < C : WithProgress + Clone + ' static > LengthPreservingContainerBuilder for CapacityContainerBuilder < C > { }
194195
195- impl < T > Container for Vec < T > {
196+ impl < T > WithProgress for Vec < T > {
196197 #[ inline] fn update_count ( & self ) -> i64 { i64:: try_from ( Vec :: len ( self ) ) . unwrap ( ) }
197198 #[ inline] fn is_empty ( & self ) -> bool { Vec :: is_empty ( self ) }
198199}
@@ -255,9 +256,9 @@ mod rc {
255256 use std:: ops:: Deref ;
256257 use std:: rc:: Rc ;
257258
258- use crate :: { Container , IterContainer , DrainContainer } ;
259+ use crate :: { WithProgress , IterContainer , DrainContainer } ;
259260
260- impl < T : Container > Container for Rc < T > {
261+ impl < T : WithProgress > WithProgress for Rc < T > {
261262 #[ inline] fn update_count ( & self ) -> i64 { std:: ops:: Deref :: deref ( self ) . update_count ( ) }
262263 #[ inline] fn is_empty ( & self ) -> bool { std:: ops:: Deref :: deref ( self ) . is_empty ( ) }
263264 }
@@ -277,9 +278,9 @@ mod arc {
277278 use std:: ops:: Deref ;
278279 use std:: sync:: Arc ;
279280
280- use crate :: { Container , IterContainer , DrainContainer } ;
281+ use crate :: { WithProgress , IterContainer , DrainContainer } ;
281282
282- impl < T : Container > Container for Arc < T > {
283+ impl < T : WithProgress > WithProgress for Arc < T > {
283284 #[ inline] fn update_count ( & self ) -> i64 { std:: ops:: Deref :: deref ( self ) . update_count ( ) }
284285 #[ inline] fn is_empty ( & self ) -> bool { std:: ops:: Deref :: deref ( self ) . is_empty ( ) }
285286 }
0 commit comments