Hoist read lock

This commit is contained in:
Greg Fitzgerald
2018-09-07 11:54:04 -06:00
parent d5f60b68e4
commit da423b6cf0
2 changed files with 6 additions and 7 deletions

View File

@ -43,7 +43,10 @@ fn broadcast(
let blobs_chunked = blobs_vec.chunks(WINDOW_SIZE as usize).map(|x| x.to_vec()); let blobs_chunked = blobs_vec.chunks(WINDOW_SIZE as usize).map(|x| x.to_vec());
if log_enabled!(Level::Trace) { if log_enabled!(Level::Trace) {
trace!("{}", window::print_window(&id, window, *receive_index)); trace!(
"{}",
window::print_window(&id, &window.read().unwrap(), *receive_index)
);
} }
for mut blobs in blobs_chunked { for mut blobs in blobs_chunked {

View File

@ -465,7 +465,7 @@ fn recv_window(
); );
} }
if log_enabled!(Level::Trace) { if log_enabled!(Level::Trace) {
trace!("{}", print_window(id, window, *consumed)); trace!("{}", print_window(id, &window.read().unwrap(), *consumed));
trace!( trace!(
"{}: consumed: {} received: {} sending consume.len: {} pixs: {:?} took {} ms", "{}: consumed: {} received: {} sending consume.len: {} pixs: {:?} took {} ms",
id, id,
@ -483,10 +483,8 @@ fn recv_window(
Ok(()) Ok(())
} }
pub fn print_window(id: &Pubkey, window: &SharedWindow, consumed: u64) -> String { pub fn print_window(id: &Pubkey, window: &Window, consumed: u64) -> String {
let pointer: Vec<_> = window let pointer: Vec<_> = window
.read()
.unwrap()
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, _v)| { .map(|(i, _v)| {
@ -499,8 +497,6 @@ pub fn print_window(id: &Pubkey, window: &SharedWindow, consumed: u64) -> String
.collect(); .collect();
let buf: Vec<_> = window let buf: Vec<_> = window
.read()
.unwrap()
.iter() .iter()
.map(|v| { .map(|v| {
if v.data.is_none() && v.coding.is_none() { if v.data.is_none() && v.coding.is_none() {