Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions bytes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ pub mod arc {
///
/// If uniquely held, this method recovers the initial pointer and length
/// of the sequestered allocation and re-initializes the BytesMut. The return
/// value indicates whether this occurred.
/// value indicates whether this occurred. A `None` value indicates that the
/// downcast to `B` failed and the type is not correct.
///
/// # Examples
///
Expand All @@ -123,19 +124,19 @@ pub mod arc {
/// drop(shared3);
/// drop(shared2);
/// drop(shared4);
/// assert!(shared1.try_regenerate::<Vec<u8>>());
/// assert_eq!(shared1.try_regenerate::<Vec<u8>>(), Some(true));
/// assert!(shared1.len() == 1024);
/// ```
pub fn try_regenerate<B>(&mut self) -> bool where B: DerefMut<Target=[u8]>+'static {
pub fn try_regenerate<B>(&mut self) -> Option<bool> where B: DerefMut<Target=[u8]>+'static {
// Only possible if this is the only reference to the sequestered allocation.
if let Some(boxed) = Arc::get_mut(&mut self.sequestered) {
let downcast = boxed.downcast_mut::<B>().expect("Downcast failed");
let downcast = boxed.downcast_mut::<B>()?;
self.ptr = downcast.as_mut_ptr();
self.len = downcast.len();
true
Some(true)
}
else {
false
Some(false)
}
}

Expand Down
2 changes: 1 addition & 1 deletion communication/src/allocator/zero_copy/bytes_slab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl BytesSlab {
if self.stash.is_empty() {
for shared in self.in_progress.iter_mut() {
if let Some(mut bytes) = shared.take() {
if bytes.try_regenerate::<BoxDerefMut>() {
if bytes.try_regenerate::<BoxDerefMut>() == Some(true) {
// NOTE: Test should be redundant, but better safe...
if bytes.len() == (1 << self.shift) {
self.stash.push(bytes);
Expand Down
8 changes: 4 additions & 4 deletions timely/src/dataflow/operators/vec/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::dataflow::operators::core::Partition as PartitionCore;
use crate::dataflow::{Scope, StreamVec};

/// Partition a stream of records into multiple streams.
pub trait Partition<G: Scope, D: 'static, D2: 'static, F: Fn(D) -> (u64, D2)> {
pub trait Partition<G: Scope, D: 'static> {
/// Produces `parts` output streams, containing records produced and assigned by `route`.
///
/// # Examples
Expand All @@ -21,11 +21,11 @@ pub trait Partition<G: Scope, D: 'static, D2: 'static, F: Fn(D) -> (u64, D2)> {
/// streams.pop().unwrap().inspect(|x| println!("seen 0: {:?}", x));
/// });
/// ```
fn partition(self, parts: u64, route: F) -> Vec<StreamVec<G, D2>>;
fn partition<D2: 'static, F: Fn(D) -> (u64, D2)+'static>(self, parts: u64, route: F) -> Vec<StreamVec<G, D2>>;
}

impl<G: Scope, D: 'static, D2: 'static, F: Fn(D)->(u64, D2)+'static> Partition<G, D, D2, F> for StreamVec<G, D> {
fn partition(self, parts: u64, route: F) -> Vec<StreamVec<G, D2>> {
impl<G: Scope, D: 'static> Partition<G, D> for StreamVec<G, D> {
fn partition<D2: 'static, F: Fn(D)->(u64, D2)+'static>(self, parts: u64, route: F) -> Vec<StreamVec<G, D2>> {
PartitionCore::partition::<CapacityContainerBuilder<_>, _, _>(self, parts, route)
}
}
4 changes: 1 addition & 3 deletions timely/src/progress/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ impl<T:Timestamp+Send> Progcaster<T> {
});

// We clone rather than drain to avoid deserialization.
for &(ref update, delta) in recv_changes.iter() {
changes.update(update.clone(), delta);
}
changes.extend(recv_changes.iter().map(|(u,d)| (u.clone(), *d)));
}

}
Expand Down
Loading