Switch to unbounded receiver for vault
This commit is contained in:
parent
e6af7e6aa1
commit
5abda48b86
2 changed files with 11 additions and 11 deletions
|
|
@ -17,13 +17,13 @@ enum Request {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Vault {
|
||||
tx: mpsc::Sender<Request>,
|
||||
tx: mpsc::UnboundedSender<Request>,
|
||||
}
|
||||
|
||||
impl Vault {
|
||||
pub async fn close(&self) {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.tx.send(Request::Close(tx)).await;
|
||||
let _ = self.tx.send(Request::Close(tx));
|
||||
let _ = rx.await;
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ impl Vault {
|
|||
}
|
||||
}
|
||||
|
||||
fn run(conn: Connection, mut rx: mpsc::Receiver<Request>) {
|
||||
fn run(conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
|
||||
while let Some(request) = rx.blocking_recv() {
|
||||
match request {
|
||||
Request::Close(tx) => {
|
||||
|
|
@ -71,7 +71,7 @@ pub fn launch(path: &Path) -> rusqlite::Result<Vault> {
|
|||
|
||||
migrate::migrate(&mut conn)?;
|
||||
|
||||
let (tx, rx) = mpsc::channel(8);
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
thread::spawn(move || run(conn, rx));
|
||||
Ok(Vault { tx })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl From<EuphRequest> for Request {
|
|||
}
|
||||
|
||||
pub struct EuphVault {
|
||||
pub(super) tx: mpsc::Sender<Request>,
|
||||
pub(super) tx: mpsc::UnboundedSender<Request>,
|
||||
pub(super) room: String,
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
id: *id,
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
root: *root,
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
root: *root,
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
root: *root,
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
room: self.room.clone(),
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ impl MsgStore<EuphMsg> for EuphVault {
|
|||
room: self.room.clone(),
|
||||
result: tx,
|
||||
};
|
||||
let _ = self.tx.send(request.into()).await;
|
||||
let _ = self.tx.send(request.into());
|
||||
rx.await.unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue