Replace RwLock with Mutex in beacon::client
... since there are never multiple readers.
This commit is contained in:
parent
41d7487ab0
commit
162f8c0c29
1 changed files with 4 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ use semver::Version;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net;
|
use tokio::net;
|
||||||
use tokio::sync::{RwLock, mpsc};
|
use tokio::sync::{Mutex, mpsc};
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ async fn run(
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let command_sender = Arc::new(RwLock::new(None));
|
let command_sender = Arc::new(Mutex::new(None));
|
||||||
|
|
||||||
match _connect().await {
|
match _connect().await {
|
||||||
Ok(stream) => {
|
Ok(stream) => {
|
||||||
|
|
@ -156,8 +156,7 @@ async fn run(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::Forward(sender) => {
|
Action::Forward(sender) => {
|
||||||
*command_sender.write().await =
|
*command_sender.lock().await = Some(sender);
|
||||||
Some(sender);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +169,7 @@ async fn run(
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(sender) = command_sender.read().await.as_ref() {
|
if let Some(sender) = command_sender.lock().await.as_ref() {
|
||||||
let _ = sender.send(command).await;
|
let _ = sender.send(command).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue