Skip to content

Commit

Permalink
edit recv_all
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed May 18, 2022
1 parent ba0e9c3 commit b5ff0c4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/fast_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ pub fn init(config: Config) -> Result<&'static Logger, LogError> {
if let Ok(mut data) = data {
let mut remain;
if LOG_SENDER.recv.len() > 0 {
remain = recv_all(&LOG_SENDER.recv);
remain.insert(0, data);
remain = Vec::with_capacity(LOG_SENDER.recv.len());
remain.push(data);
recv_all(&mut remain,&LOG_SENDER.recv);
} else {
remain = vec![data];
}
Expand Down Expand Up @@ -190,8 +191,7 @@ pub fn init(config: Config) -> Result<&'static Logger, LogError> {
}
}

fn recv_all<T>(recver: &Receiver<T>) -> Vec<T> {
let mut data = Vec::with_capacity(recver.len());
fn recv_all<T>(data: &mut Vec<T>,recver: &Receiver<T>) {
loop {
match recver.try_recv() {
Ok(v) => {
Expand All @@ -202,7 +202,6 @@ fn recv_all<T>(recver: &Receiver<T>) -> Vec<T> {
}
}
}
data
}


Expand Down

0 comments on commit b5ff0c4

Please sign in to comment.