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

Removed unbounded member of FsLock #14

Merged
merged 2 commits into from Aug 28, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/private.rs
Expand Up @@ -7,7 +7,7 @@ pub struct FsSync<T> {
pub receiver_idx: Option<usize>,
pub receiver_max_idx: Option<usize>,

pub write_bounds: VecDeque<(usize, usize)>, // yikes, unbounded
pub write_bound: Option<usize>,
pub writes_to_read: usize,

pub sender_idx: usize,
Expand All @@ -28,7 +28,7 @@ impl<T> FsSync<T> {
receiver_idx: None,
receiver_max_idx: None,

write_bounds: VecDeque::with_capacity(128),
write_bound: None,
writes_to_read: 0,

sender_idx: 0,
Expand Down
4 changes: 1 addition & 3 deletions src/receiver.rs
Expand Up @@ -102,9 +102,7 @@ impl<T> Receiver<T>
fslock.receiver_read_id = fslock.receiver_read_id.wrapping_add(1);

if fslock.receiver_idx.is_none() {
let bnds = fslock.write_bounds.pop_back().expect("NO BOUND");
fslock.receiver_idx = Some(bnds.0);
fslock.receiver_max_idx = Some(bnds.1);
fslock.receiver_idx = Some(fslock.write_bound.expect("NO BOUND"));
}
if fslock.receiver_idx.unwrap() < fslock.in_memory_idx {
let event = fslock
Expand Down
13 changes: 4 additions & 9 deletions src/sender.rs
Expand Up @@ -177,17 +177,12 @@ impl<T> Sender<T>
}
}
fslock.writes_to_read += 1;
if fslock.sender_captured_recv_id == fslock.receiver_read_id &&
!fslock.write_bounds.is_empty() {
fslock.sender_idx += 1;
fslock.write_bounds[0].1 = fslock.sender_idx;
} else {
if (fslock.sender_captured_recv_id != fslock.receiver_read_id) ||
fslock.write_bound.is_none() {
fslock.sender_captured_recv_id = fslock.receiver_read_id;
fslock
.write_bounds
.push_front((fslock.sender_idx, fslock.sender_idx));
fslock.sender_idx += 1;
fslock.write_bound = Some(fslock.sender_idx);
}
fslock.sender_idx += 1;
}

/// Return the sender's name
Expand Down