Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
fix bugs when get lock
  • Loading branch information
ipconfiger committed Jan 5, 2024
1 parent ab8b1d0 commit 136db5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ timer = "0.2.0"
lettre = { version = "0.10.4", default-features = false, features = ["builder", "smtp-transport", "rustls-tls"] }
dirs = "3.0.2"
reqwest = { version = "0.11.23", default-features = false, features = ["blocking", "json", "rustls-tls"] }

rdkafka = { version = "0.33.2", default-features = false, features = ["cmake-build"] }

[dev-dependencies]
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ impl QueueGroup {
}
fn push_to(&mut self, chn: i32, msg: &String) {
let q: &Arc<Mutex<VecDeque<String>>> = self.queues.get(chn as usize).unwrap();
let mut queue = q.lock().unwrap();
queue.push_back(msg.to_string());
while let Ok(mut queue) = q.lock() {
return queue.push_back(msg.to_string());
}
}
fn shorted_chn(&mut self) -> i32 {
let rg = 0..self.size;
Expand All @@ -106,7 +107,7 @@ impl QueueGroup {
fn get_queue_len(&mut self, chn: i32) -> usize {
if let Some(q) = self.queues.get(chn as usize) {
println!("获取到{}的信箱", chn);
if let Ok(queue) = q.lock() {
while let Ok(queue) = q.lock() {
return queue.len();
}
}
Expand Down

0 comments on commit 136db5d

Please sign in to comment.